0
votes

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
We don't have enough information here to help you. HOW do you want the multiple(?) UserControls within this Panel resized? So they take up equal space horizontally, vertically, in a grid?...something else? Take a look at the FlowLayoutPanel and the TableLayoutPanel for something to start with.Idle_Mind
Can you show code on how you are creating a control and adding it to the Panel?mclark1129
I've edited the question to show how my user controls are added to the panel- disposeUCs() simply removes the current user control from the panel when a new user control has been selected for viewing. Please look at the image link I've provided in the question.Nick

1 Answers

0
votes

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)