Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto resize a Form on a Panel 1

Status
Not open for further replies.

RyanEK

Programmer
Apr 30, 2001
323
0
0
AU
Hi,

I currently place a Form on a Panel. ie.

Code:
Form1 frm = new Form1();
frm.TopLevel = false;
frm.Parent = this.panel1;
frm.Show();

To get this form to fill the entire space of the Panel I call...

Code:
frm.WindowState = FormWindowState.Normal;
frm.WindowState = FormWindowState.Maximized;

Is there another way? This method does not resize the Form if the Panel itself is resized. In effect, I need to Dock the Form but frm.Dock = DockStyle.Fill does not work.

A star for any helpful answer!

Thanks
Ry
 
Hello,

This code in the main form load event worked for me in VS 2005:
Code:
    PanelForm pForm = new PanelForm(); 
    pForm.TopLevel = false; 
    pForm.Visible = true; 
    this.Panel1.Controls.Add(pForm); 
    pForm.Dock = DockStyle.Fill;
Good Luck!
 
Thanks for the reply. It turns out the DockStyle.Fill only works if the form has a WindowState = FormWindowState.Normal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top