Click here to Skip to main content
15,868,164 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi
I want to load a Form in a Control Like PanelControl in c# Windows Form

but Form2 did not apeared in Form1.Panel1.
without eny error or exeption.

I do like this:
Form2 frm = new Form2();
frm.TopLevel = false;
frm.Dock = DockStyle.Fill;
panel1.Controls.Add(frm);

and i do in this way with same result:

panel1.Controls.Add(new Form2() {TopLevel = false,Dock=DockStyle.Fill });
Posted

1 solution

You just missed to use Show() of Form
you need to use given code

Form2 frm = new Form2();
frm.TopLevel = false;
frm.Dock = DockStyle.Fill;
frm.Show(); // Shows the form with specified owner to user
this.panel1.Controls.Add(frm);


It will works
:)
 
Share this answer
 
v2
Comments
SepantaNima 16-Nov-10 9:58am    
Tanks For Your Help
That is true

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