anchoring

S

Steve

I have two group boxes containing labels and textboxes that are next too
each other. I want the group boxes and labels and textboxes to remain
portionally the same as the form is resized.

I've set the group boxes to be anchored left, right, top, and bottom, the
labels to be left, right, top, and the textboxes to be anchored left,
right,top, and bottom.

But when I try to manually resize the form, the group boxes overlap. How do
I get the group boxes and contents to stay properly the same while growing?

Thanks
 
S

Steve

A little more information
The group boxes overlap in the middle when resizing in either direction.
 
J

Jay B. Harlow

But when I try to manually resize the form, the group boxes overlap. How
do
I get the group boxes and contents to stay properly the same while
growing?
Don't anchor both left groupbox to the right side and the right groupbox to
the left side. As this will cause them to overlap when the form resizes. As
each will remain fixed to the opposite side...

Consider:
- anchoring only one of them

- using a TableLayoutPanel (VS 2005)
http://msdn2.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.aspx

Where you anchor each groupbox into a cell of the TableLayoutPanel. Each
cell would have a width of 50%.

-using the Form.Layout event

http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.layout.aspx

Something like (which needs some more work):

Private Sub MainForm_Layout(ByVal sender As Object, ByVal e As
System.Windows.Forms.LayoutEventArgs) Handles Me.Layout
Dim width As Integer = Me.ClientSize.Width \ 2
GroupBox3.Width = (width - Me.GroupBox3.Left -
Me.GroupBox3.Padding.Right)
GroupBox4.Width = (width - Me.GroupBox4.Padding.Horizontal)
GroupBox4.Left = Me.ClientRectangle.Right - GroupBox4.Width -
Me.GroupBox4.Padding.Right
End Sub
 
C

Cor Ligthert [MVP]

Steve,

This means in my idea that you have only put some anchors on the outer side.

See anchoring as with a ship. If they have no anchors in the middle the
possibilitiy exist that they hit each other when the sea is lowering.

Cor
 

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