Is FlowLayoutPanel AutoSize Vertical Only?

I am loading images dynamically inside a FlowLayoutPanel . I need this panel for automatic tuning, but only vertically.

Is this possible, and if so, how can I achieve it?

+7
source share
3 answers

Simple, add a type control event added:

 private void flowLayoutPanel1_ControlAdded(object sender, ControlEventArgs e) { if (flowLayoutPanel1.Controls.Count % 10 == 0) flowLayoutPanel1.SetFlowBreak(e.Control as Control, true); } 

set AutoSize = true

set flowdirection = LeftToRight

+11
source

I set the size from the panel dynamically. Example:

 int newHeight= listImages.Count/10 * 100; flowLayoutPanel1.Size = new Size(1143, newHeight); 

This works for me. thanks all

+1
source

This may seem like an ugly solution, but it works for me:

  1. Save the current panel width in a variable;
  2. Set AutoSize mode to true;
  3. Perform an action that requires resizing the panel;
  4. Restore the previous panel width from a variable.

      int i = _panel1.Width; _panel1.AutoSize = true; _panel1.AutoSizeMode = AutoSizeMode.GrowOnly; /*some action going on here*/ _panel1.AutoSize = false; _panel1.Size = new Size(_panel1.Width, 80); 
0
source

All Articles