Hello:
Is there a simple way to change the text of a button on a MDI Child form from the MDI Parent before doing a ShowDialog of the MDI Child?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Hirendra SisodiyaPosted Feb 22, 2010, 12:57 AM
use code like this:
FrmChild frm = new FrmChild ();
frm .txtBox.Text = OK";
frm .Show();
theLizardPosted Feb 21, 2010, 3:43 PM
On your child form declare a Button ButtonChild as public before the initializeComponent() then in form load assign the ButtonChild to the button you want access to.
eg ButtonChild = BtnSave
You now have ALL properties etc available to you from any form...
In your mdi when you instantiate a new form you simply change the text of the public button ButtonChild and BtnSave will have the text of ButtonChild since they are one and the same.
I hope you understand what I mean.
Form1 f = new Form1();
f.ButtonChild.Text = "&Save";
f.Show();
Cant't get any simpler...
Karan PatelPosted Feb 20, 2010, 11:02 PM
// here f1 is a child form instance.
private void button1_Click(object sender, EventArgs e)
{
Form1 f1 = new Form1();
f1.Controls["button1"].Text = "hello world";
f1.ShowDialog();
}
NainilPosted Feb 20, 2010, 10:55 PM
You can probably expose a property on your MDI child form which sets the Label's Text. Just before you call Show() on a MDIChild, you can set the property of the MDI child which set's the lablel's Text. I have attached a sample for your reference.
kiran kumarPosted Feb 20, 2010, 10:48 PM
before doing a showdialog,you call a function in child form from parent form supplying arguments..assign button text to supplied argument under the function in child form...
MARK THE ANSWER IF IT HELPS YOU