usercontrol resizing dock anchoring parent vb.net

M

marfi95

My application consists of basically a treeview on the left side,
along with a panel control that takes up the right side. When nodes
are clicked on the left, the data on the right side of the panel is
changed based on that type.

What I'm using are usercontrols, so I can do the visual design of them
in a separate window. when the node is clicked, I assign the parent
of the usercontrol to the panel control that is on the right side of
the window. this is all working great except for a small problem. I
can't get the usercontrol to respect the docking/anchoring properties
so that when the screen is maximized the controls on the usercontrol
get adjusted automatically.

The main control on each usercontrol is a panel that is set to Dock-
Fill. All other controls are placed within this panel accordingly
with Top,Left anchoring. I thought that was all I had to do so that
the panel got filled, but I guess the usercontrol panel is only
filling to the size of the usercontrol.

How do i get the usercontrol to resize (and all of its controls) based
on the size of its parent (which is the panel on the main form).

Hope that made sense.

Thanks !
Mark
 
G

Guest

The main control on each usercontrol is a panel that is set to Dock-
Fill. All other controls are placed within this panel accordingly
with Top,Left anchoring. I thought that was all I had to do so that
the panel got filled, but I guess the usercontrol panel is only
filling to the size of the usercontrol.

Did you dock or anchor the user control itself to the parent form?

Also each control within the user control/panel needs to be anchored
properly as well.
 
P

Phill W.

marfi95 said:
My application consists of basically a treeview on the left side,
along with a panel control that takes up the right side. When nodes
are clicked on the left, the data on the right side of the panel is
changed based on that type.
when the node is clicked, I assign the parent of the usercontrol to the
panel control that is on the right side of the window.

I'd expect to see something more like

RightPanel.Controls.Add( userControl )

but they /probably/ do much the same things, under the covers.
How do i get the usercontrol to resize (and all of its controls) based
on the size of its parent (which is the panel on the main form).

Follow the above with

' You'll need this if SuspendLayout has been called
userControl.Size = Rightpanel.ClientSize

' Get the UserControl to fill the panel
userControl.Dock = DockStyle.Fill

HTH,
Phill W.
 
M

marfi95

I'd expect to see something more like

RightPanel.Controls.Add(userControl)

but they /probably/ do much the same things, under the covers.


Follow the above with

' You'll need this if SuspendLayout has been calleduserControl.Size = Rightpanel.ClientSize

' Get theUserControlto fill the paneluserControl.Dock = DockStyle.Fill

HTH,
Phill W.

Didn't seem to help. This is basically the code in the main form when
the treenode is selected

userControlList(i).Visible = True
userControlList(i).Parent = Me.pnlBottomRight
userControlList(i).size = pnlBottomRight.Size
userControlList(i).dock = DockStyle.Fill
userControlList(i).PopulateData()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top