Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FlowLayoutPanel - Automatic Width for controls?

is it possible to make the inserted items in FlowLayoutPanel automatic size of the FlowLayoutPanel? Here is an example:

A form with 1 FlowLayoutPanel and 3 buttons inside:

enter image description here

if I resize the form, the controls look like this: they arrange "left to right"

enter image description here

What I want is this: The controls should have the width of the FlowLayoutPanel:

enter image description here

Any Ideas how to do this? I changed the FlowDirection and played with the Anchor property but with no luck.

I could of course Resize the controls in the FlowLayoutPanel_Resize event, but I want to add about 500 usercontrols - I tested it and it is slow.

like image 994
MilMike Avatar asked Mar 22 '11 18:03

MilMike


1 Answers

I suggest you using TableLayoutPanel with one column in this case. I have found TableLayoutPanel much more predictable and solid than FlowLayoutPanel.

Another option, if you still want to use FlowLayoutPanel, is to set first control width to desired one, and use Dock = Top for all other controls.

like image 140
arbiter Avatar answered Sep 27 '22 17:09

arbiter