Home All Groups Group Topic Archive Search About
Author
17 Dec 2006 8:26 PM
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

Author
17 Dec 2006 9:12 PM
Steve
A little more information
The group boxes overlap in the middle when resizing in either direction.

Show quoteHide quote
"Steve" <s.ar***@comcast.net> wrote in message
news:%23MDhCmhIHHA.1252@TK2MSFTNGP02.phx.gbl...
> 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
>
>
Author
17 Dec 2006 10:39 PM
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


--
Hope this helps
Jay B. Harlow
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


Show quoteHide quote
"Steve" <s.ar***@comcast.net> wrote in message
news:%23MDhCmhIHHA.1252@TK2MSFTNGP02.phx.gbl...
>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
>
>
Author
18 Dec 2006 6:05 AM
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

Show quoteHide quote
"Steve" <s.ar***@comcast.net> schreef in bericht
news:%23MDhCmhIHHA.1252@TK2MSFTNGP02.phx.gbl...
>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
>
>