Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
Here i is have 4 forms(Form1, Form2, Form3 and Form4) Form1 is MdiContainer(IsMdiContainer = true;), Form2, Form3 and Form4 are Mdichild forms.
In Form1 Load event i wrote the code as follows:
C#
private void Form1_Load(object sender, EventArgs e)
     {
         Form2 f2 = new Form2();
         f2.MdiParent = this;
         f2.ShowDialog(); 
     }

In Form2 form i have two buttons called "btnf3"and "btnf4".
1.If i click on "btnf3"
i wnat to open Form3 as a MDI child form of Form1 and also this Form2 has to be closed. (for closing this i wrote this.Hide();)
2.If i click on "btnf4" i want to open Form4 as a MDI Child form of Form1 and also close Form2 (MDI child form) has to be closed.

Please tell me what should i write in those buttons click events
Thanks... in advance.
Posted
Updated 31-May-12 18:11pm
v2
Comments
Maciej Los 31-May-12 16:26pm    
Where is a problem?

Here is the best way of doing things right: never using MDI.

Here is the idea: who needs MDI, ever? Why torturing yourself and scaring off your users?
Do yourself a great favor: do not use MDI at all. You can do much easier to implement design without it, with much better quality. MDI is highly discouraged even by Microsoft, in fact, Microsoft dropped it out of WPF and will hardly support it. More importantly, you will scare off all your users if you use MDI. Just don't. I can explain what to do instead.

Please see:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[^],
How to Create MDI Parent Window in WPF?[^].

And please also see my past answers explaining what to do:
Question on using MDI windows in WPF[^],
MDIContainer giving error[^],
How to set child forms maximized, last child form minimized[^].

Good luck,
—SA
 
Share this answer
 
Comments
Maciej Los 31-May-12 17:33pm    
Here is the best way of doing things right: never using MDI. - as i wrote previous - interesting advice ;)
+5!
Sergey Alexandrovich Kryukov 31-May-12 20:15pm    
Again: it works! :-)
--SA
VJ Reddy 1-Jun-12 2:26am    
Good answer and advice. 5!
Sergey Alexandrovich Kryukov 1-Jun-12 10:21am    
Thank you, VJ.
--SA
anilkumar.6714 1-Jun-12 11:34am    
Thank you
Take a look at similar discussion: How to Open Child Window in tab[^]
 
Share this answer
 
Comments
VJ Reddy 1-Jun-12 2:27am    
Good reference. 5!
Maciej Los 1-Jun-12 2:49am    
Thank you, VJ ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900