Click here to Skip to main content
15,907,493 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hello all,

I have 3 forms like form1,form2 and form3. So i want to add like this..

form1.controls.add(from2);
form2.controls.add(from3);

is it possible....

Thanks in advance
Posted
Comments
Sergey Alexandrovich Kryukov 12-Apr-12 2:58am    
Why? why?! Anyway, I do have a complete answer, but I don't advise to do it...
--SA

1 solution

Yes, it is possible, but you should not do it. The result is ugly and violates intended window usage.

Still want to see all the ugliness? OK, I can explain how.

First of all, the parent/child relationships between forms is done defunct. If you try to call the methods you have shown of assign form1.Parent = form2, exception will be thrown. You still can force such bad calls using the property System.Windows.Forms.Form.TopLevel — assign it to false for a form to be done a child. Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.toplevel.aspx[^].

Try it and see how it works, but never do it for real applications — no one will say thank you for that. For children, use any other controls.

—SA
 
Share this answer
 
v3
Comments
VJ Reddy 12-Apr-12 3:32am    
Good advice. 5!
Sergey Alexandrovich Kryukov 12-Apr-12 10:23am    
Thank you, VJ.
--SA

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