Anchoring controls within a panel

1k views Asked by At

My form contains a panel which is used to add/dispose of several user controls (based on the selection of from the menustrip). Prior to using this panel to contain each user control, I could anchor and therefore resize each user control when the form resized. Despite the panel resizing correctly with the form, I can't figure out how to anchor the user controls within the panel so that they will also resize.

Example of panel in yellow, user control in red: http://gyazo.com/390f85587335efee4a9ec8b913ffce06

Any suggestions would be appreciated.

disposeUCs()

        Dim _UCAddNewRawMaterial As New UCAddNewRawMaterial
        Panel1.Controls.Add(_UCAddNewRawMaterial)
1

There are 1 answers

1
Idle_Mind On BEST ANSWER

It sounds like you'll only ever have one UserControl in the Panel at a time?

If so, simply DockStyle.Fill it:

Dim _UCAddNewRawMaterial As New UCAddNewRawMaterial
_UCAddNewRawMaterial.Dock = DockStyle.Fill
Panel1.Controls.Add(_UCAddNewRawMaterial)