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();
}

Re: Form -> Panel -> Child Form -> Resize -> Bug? by VJ

VJ
Wed May 10 09:41:04 CDT 2006

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

"Mark Newmister" <mnewmister@iwanttss.com> wrote in message
news:OUt2BQ6cGHA.1792@TK2MSFTNGP03.phx.gbl...
> 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();
> }
>
>