Nasir Mahmood
Nasir Mahmood

Reputation: 1505

How do I reposition a groupbox on a form?

I have two group boxes, the top one is collapsible. I want to adjust the layout of the lower group box when the upper group box collapses or expands.

Upvotes: 0

Views: 262

Answers (3)

LarsTech
LarsTech

Reputation: 81620

A SplitContainer can help in this type of display.

splitContainer1.Orientation = Orientation.Horizontal;
splitContainer1.IsSplitterFixed = true;

And then in each panel in the SplitContainer control, you place your GroupBoxes with both their Dock settings set to Fill.

When collapsing the top panel, you let the SplitContainer handle it:

splitContainer1.Panel1Collapsed = !splitContainer1.Panel1Collapsed;

Upvotes: 0

hawbsl
hawbsl

Reputation: 16003

In addition to @Marco's suggestion, another option is the FlowLayoutPanel. It's useful when you want to ensure nearby controls adapt to fill the space when a control is resized.

Upvotes: 0

Marco
Marco

Reputation: 57583

Use Dock property: set the first to Top and the second to Fill

Upvotes: 1

Related Questions