We added the property "Dock = Dockstyle.Fill" to our FlowLayoutPanel so that it resizes and fills its parent control. Now we added two GroupBoxes to the FlowLayoutPanel. These should have the same width as the Panel, but when we use "Dock = Dockstyle.Top" it doesn't work.
Problem is, we tried to set the width with "Width = Parent.Width". That would work but with our approach, to create the UI via a XML File, at the moment we want to set the width, the GroupBoxes doesn't have a parent yet. It will be added to the FlowLayoutPanel later.
By the way we also added the "FlowDirection = TopDown" to the FlowLayoutPanel, but if the GroupBoxes become smaller it places them side by side instead of TopDown.
So we are looking for a way to get all controls beneath each other and to get all GroupBoxes the same width as the FlowLayoutPanel.
Thanks for every help,
Dominic
In the case that you described, when you only want top-down flow, you can simply use Panel instead of FlowLayoutPanel. Set the panel
AutoScroll
to true, and itsDock
toFill
and then add group boxes to panel and setDock
property of them toTop
.Note:
For future uses of
FlowLayoutPanel
you may find this helpful:Example:
For example following, if you run following code:
The result will be:
You can reverse the order of items, by uncommenting the comment code.