Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to make more than one child forms(different forms for different purpose).
can any one plz help me with coding for creating more than one child forms(different forms for different purpose).
Posted
Updated 25-May-11 20:22pm
v2
Comments
Mathew Crothers 26-May-11 2:27am    
Are you talking about have an MDI parent form containing more than one child form?

Start with a walkthrough on MDI forms - Creating MDI application using C# (Walkthrough)[^].
 
Share this answer
 
sorry,i first.sorry,i firstsorry,i firstsorry,i firstsorry,i firstsorry,i firstsorry,i first
 
Share this answer
 
You should create a Form and make it an MdiContainer[^]. You can do this by setting the IsMdiContainer Property of the Form to True. After you have done this you can start up new forms from your MdiContainer and give the MdiContainer as MdiParent, like this:
C#
ChildForm frm = new ChildForm();
frm.MdiParent = this;
frm.Show();

You can repeat this for every new Form.
 
Share this answer
 
There is not such concept as child and parent form.

(There is MDI Child and MDI Parent, but this is not the same. Besides, I recommend never use MDI, see http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[^], Question on using MDI windows in WPF[^], MDIContainer giving error[^].)

However, there is another important relationship: owner form and owned form. I recommend to make all forms owned by the main form. The main form is the one passed as an argument to Application.Run. When it's closed, normally the whole application is closes. Establish the forms owner using its instance property System.Windows.Forms.Form.Owner. If the form is owned, also good to set Form.ShowInTaskbar = false.

Why it this important? When all forms are linked with ownerships which goes up to the main form, all forms are always activate together. If you activate one form, all other forms of the application goes on top of other forms, and the form you activate goes on very top (again, only if you establish Owner properties). As all forms activates together, you don't need individual forms on the task bar. Let your main form represent the whole application.

Try it and see how it works.
You can add as many forms in addition to the main form. I advice you keep them to minimum. Two forms for one application is more than enough, tree is too many. You can make it much like MDI (multiple SDI), but this is not so good thing. It's much better to have only one main form, but with tabbed interface. Or dockable, like Visual Studio.

—SA
 
Share this answer
 

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