I have a MDI form. within this MDI form I can open some child forms using:
This is within MainForm
Form1 f1 = new Form1;
f1.MdiParent = this; //this refers to MainForm (parent)
f1.Show();
This works as expected!
But Now, while I am in the child form (Form1 -> f1) I want to open another form as a child for MainForm
but when I use this
keyword it will reffer to f1
. How can I open the new form within f1
and set its MdiParent
to MainForm
?
Try assigning the parent form of your first child from:
Form2 f2 = new Form2;
f2.MdiParent = this.ParentForm; //this refers to f1's parent, the MainForm
f2.Show();
Hope this helps.
Well, not to argue with the "solution" that was listed... but if I'm understanding the request correctly and trying the above solution didnt work i would do the following....
Form2 f2 = new Form2();
f2.MdiParent = MDIParent1.ActiveForm;
f2.Show();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With