Click here to Skip to main content
12,504,002 members (55,337 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# C#4.0
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 16-Nov-10 3:46am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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
:)
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160919.1 | Last Updated 16 Nov 2010
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100