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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Anchor Problems with nested controls

Status
Not open for further replies.

emeraldtea

Programmer
Mar 4, 2003
16
US
I have a Form, in the form a Panel and in the Panel a listbox.

When I do this in a single file(all form, panel and listbox located in the same file). And I set:
this.panel.Anchor = AnchorStyles.Left | AnchorStyles.Right |..Top |..Bottom;
this.listbox.Anchor = AnchorSytles.Left |..Right |..Top |..Bottom;

When I expand the form, the panel and listbox both expand accordingly.

But this is the simplest form only for practising in VS.

In my application, I have a Main in the form and in the form class, I add a panel object of another class(the listbox is in the panel).
In the form I have the Anchor statements as:
this.panel.Anchor = AnchorStyles.Left | AnchorStyles.Right |..Top |..Bottom;
this.panel.listbox.Anchor = AnchorSytles.Left |..Right |..Top |..Bottom; (I use this.panel.listbox here as listbox is in panel).

When the form is expanded, the panel expands but not the listbox.
Why is it?

I try another way: set the Anchor of listbox in the panel class where it is locasted instead of in the form class. It doesn't work either.

It should be.
Any comments?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top