I am trying to create an application that opens in one form and within that form I can have multiple windows forms.
Loading
I am trying to create an application that opens in one form and within that form I can have multiple windows forms.
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.
vivek kulkarniPosted Apr 30, 2009, 9:20 AM
Hi Maria,
Sorry for a late reply was a little busy.
Here is the code u need to use in the form2 button click event.
Form3 obj = new Form3();obj.MdiParent =
this.MdiParent;obj.Show();
Thank you,
MariaPosted Apr 27, 2009, 3:24 PM
Thanks for your post. For some reason this code is not working for me. I get an error stating 'WindowsApplication1.Form1' is a 'type' but is used as a 'variable'. :(
vivek kulkarniPosted Apr 27, 2009, 11:48 AM
Hi Maria,
You can have as many child forms as you want. you have to set the MDIParent property to point to the form which is the MDI parent.
In the button click event of the form2 write the following code.
public void Button1_Click(...)
{
Form3 obj = new Form3();
obj.MDIParent= Form1;
obj.Show();
}
Thank you,
MariaPosted Apr 26, 2009, 6:51 PM
Now what if I want the child form to open up another form within the parent. For example...
form1 is the parent and form2 is the child. I want when I click a button in form2 form3 opens within form1.
MariaPosted Apr 26, 2009, 11:42 AM