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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
kiran kumarRank #3,110 · 461 reputationPosted Feb 20, 2010, 5:48 PM EST
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
Nainil148 reputationPosted Feb 20, 2010, 5:55 PM EST
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.
Karan Patel120 reputationPosted Feb 20, 2010, 6:02 PM EST
// 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();
}
theLizardRank #1,079 · 1.8K reputationPosted Feb 21, 2010, 10:43 AM EST
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...
Hirendra SisodiyaRank #258 · 9.8K reputationPosted Feb 21, 2010, 7:57 PM EST
use code like this:
FrmChild frm = new FrmChild ();
frm .txtBox.Text = OK";
frm .Show();