I am trying to create an application that opens in one form and within that form I can have multiple windows forms.
Multiple forms
5 Answers
Know the answer? Post it. Somebody with the same question will find it here.
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.
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
vivek kulkarni132 reputationPosted Apr 30, 2009, 5:20 AM EDT
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,
Maria71 reputationPosted Apr 26, 2009, 7:42 AM EDT
Maria71 reputationPosted Apr 26, 2009, 2:51 PM EDT
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.
vivek kulkarni132 reputationPosted Apr 27, 2009, 7:48 AM EDT
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,
Maria71 reputationPosted Apr 27, 2009, 11:24 AM EDT
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'. :(