Cannnot resize Child Controls in a FlowLayoutPanel Control
Asked Answered
D

2

6

Description I was trying to create a FlowLayoutPanel that can be extended, for instance in the horizontal way.

FlowLayoutPanel and its sub component anchor has been set to Top-Left-Right

FlowLayoutPanel direction has been set to TopDown.

-> When rezising the FlowLayoutPanel, its sub- components are not resized accordinally.

Step to reproduce

  1. Create a FlowLayoutPanel control on your form.

  2. Set the FlowDirection of the FlowLayoutPanel to TopDown.

  3. Create a Button controls, and place it in the FlowLayoutPanel control.

  4. Select the Button and the FlowLayoutPanel and set their Anchor to Top-Left-Right

  5. Try to Extend FlowLayoutPanel on the horizontal way.

-> FlowLayoutPanel is resized but not the Button

Dymoke answered 4/12, 2009 at 0:44 Comment(0)
I
7

The FlowLayoutPanel is only meant to layout it's child controls in a dynamic way. This does not mean that they will automatically resize within the FlowLayoutPanel. I'm guessing that the FlowLayoutPanel ignores the Anchor properties of it's child controls.

To achieve this effect you'll need to manually resize your child controls on the FlowLayoutPanel's SizeChanged event.

At this point though, you may want to reconsider whether the FlowLayoutPanel is really what you want to be using. If you know that you always want a button to fill the width of the FlowLayoutPanel, you might as well stick it in a Panel and use the anchors, or set it's Dock property.

Inadvisable answered 22/1, 2010 at 17:35 Comment(0)
C
5

FlowLayoutPanel control calculates the width of an implied column from the widest child control in the column. All other controls in this column with Anchor or Dock properties are aligned or stretched to fit this implied column. The behavior works in a similar way for horizontal flow directions. The FlowLayoutPanel control calculates the height of an implied row from the tallest child control in the row, and all docked or anchored child controls in this row are aligned or sized to fit the implied row.

check msdn documentation here http://msdn.microsoft.com/en-us/library/ms171633.aspx

Contrail answered 15/4, 2013 at 17:59 Comment(1)
There needs to be an option like "FlowBreak" which allows you to set the resize option for individual controls. I have a similar situation where there's one particular panel within the overall set of controls that I want to always take up the full width, but I still want the automatic layout for everything else. The current setup I have to choose one or the other... I want both.Inchmeal

© 2022 - 2024 — McMap. All rights reserved.