Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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
Smile | :)
  Permalink  
v2
Comments
SepantaNima at 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
0 OriginalGriff 278
1 Sergey Alexandrovich Kryukov 236
2 PhilLenoir 179
3 ChauhanAjay 166
4 ClimerChinna 150
0 Sergey Alexandrovich Kryukov 6,140
1 OriginalGriff 5,195
2 CPallini 2,473
3 Richard MacCutchan 1,607
4 Abhinav S 1,505


Advertise | Privacy | Mobile
Web04 | 2.8.140814.1 | Last Updated 16 Nov 2010
Copyright © CodeProject, 1999-2014
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