The following situation:
Panel control with Dock=Fill, inside a panel an embedded form with controls
in it.
The code embedding the form into the panel is this:
pnl.Controls.Add(form1);
Everything is working perfect, except the Anchor property of controls on the
embedded form is not working. The form has a grid that should be anchored to
all four sides, however, because the form is embedded into the panel, this
whole design is not working.
Am I missing anything? Any workaround?
Thank you in advance.
Cezar

I got it! by Cezar

Cezar
Thu Mar 10 17:45:04 CST 2005

Yes, I figured it out:
I need to call:
form.Anchor = ((AnchorStyles)((AnchorStyles.Bottom | AnchorStyles.Left |
AnchorStyles.Top | AnchorStyles.Right)));

The trouble was that the Anchor property was not available to the form in
the design time, and this is why I didn't know how to accomplish this.
However, at run time the property is perfectly available, so it's fine now..



Re: Embedded form and Anchor property by Herfried

Herfried
Thu Mar 10 17:54:26 CST 2005

"Cezar" <Cezar@discussions.microsoft.com> schrieb:
> Panel control with Dock=Fill, inside a panel an embedded form with
> controls
> in it.
> The code embedding the form into the panel is this:
> pnl.Controls.Add(form1);
> Everything is working perfect, except the Anchor property of controls on
> the
> embedded form is not working. The form has a grid that should be anchored
> to
> all four sides, however, because the form is embedded into the panel, this
> whole design is not working.

Depending on the situation using a usercontrol instead of the embedded form
might be more appropriate.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>