Form -> Panel -> Child Form -> Resize -> Bug?

M

Mark Newmister

I'm using the following code to show/hide a form located inside a panel that
is located on my main form. The panel is set to DockStyle.Fill so that when
the main form is resized the panel is also resized. The problem is that the
included child form never resizes beyond it's initial starting size. Don't
child forms respect the DockStyle setting during resize of parent controls?
If I take out the commented lines of code it works - but of course it looks
like crap while doing it.

Button click event:

if (f2 == null)
{
f2 = new Form2();
f2.TopLevel = false;
this.pnl_childform.Controls.Add(f2);
}

if (!f2.Visible)
{
f2.Show();
f2.BringToFront();
f2.Dock = DockStyle.Fill;
//f2.WindowState = FormWindowState.Minimized;
//f2.WindowState = FormWindowState.Maximized;
}
else
{
f2.Hide();
}
 
V

VJ

Never tried this before.. but from experience.. I believe the Max and Min
size of Form's property has a effect over the DockStyle.. so you may want to
consider those 2 properties..

VJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top