Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi every one ,, i want to Load a winForm inside of panel !!!
is that possible ?! Or not ...

you know in asp.net we can load web pages together with JQuery
like

JavaScript
$("#Container").load("/SomeDirectory/A.aspx");

and i want to implimment somthing like that in winapp !!!
Posted

First of all, parent-child relationship between form and other controls is intentionally rendered partially defunct: a form can be a parent of a non-form control, not the opposite. This limitation can be removed is you assign false to Form.TopLevel, but — never do it; it makes no sense. The form will be shown inside the panel with all its non-client areas (if any), in all the ugliness. You never really need it.

Instead, you can design your form properly. If you describe what functionality leads you to such weird design ideas, you might get an advice of more adequate design.

The analogy with your jQuery example is incomplete. The control Form is special in this library. In a Web application, the "main form" is the Browser window, which you never "touch".

—SA
 
Share this answer
 
Its easy to do so, for example if you want to load form 3 at a panel in form 2 all you have to do is to put a panel with public modifier in form 3 then put all your controls and in form 2 you call the form 3 this way
C#
Form3 f3=new Form3();
f3.panel1.Parent=panel2;        //panel1 is the public panel in form3 and panel2 is the panel in form2 you want to load your form in
f3.Show();
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 17-Feb-13 11:58am    
This is not a form in panel; this is a panel in panel. A form can be inserted in panel, but not in such a simple way, besides, doing so is useless. Sorry for my vote of 1.
—SA
a1mimo 17-Feb-13 12:03pm    
I don't mind the vote at all we all learn but this way works and as I said if he put the panel in form as the base of the form this will load his form there you can try it I always use this way, thanks for your comment
Sergey Alexandrovich Kryukov 17-Feb-13 12:07pm    
Yes, it works, but please read the question. f3.Parent is null. OP asks for f3.Parent = somePanel. It will throw exception "control is not top-level". Please see my answer where I explain it all.
—SA
a1mimo 17-Feb-13 12:14pm    
I know what you mean but as you said in your answer this would be useless and the next best solution for him is to do as I mentioned this will give him what he wants in another way, by the way if you have some knowledge in android I have an unanswered question about it please help :-)
Sergey Alexandrovich Kryukov 17-Feb-13 12:37pm    
Sorry, the only little problem is: I never had Android in my hands, don't have an idea why would I... :-)
—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