I want to add dynamic buttons inside the FlowLayoutPanel. The outline is:
{
flowLayoutPanel1.Controls.Clear();
flowLayoutPanel1.FlowDirection = FlowDirection.LeftToRight;
flowLayoutPanel1.AutoScroll = true;
flowLayoutPanel1.SuspendLayout();
for (int i = 0; i < 15; i++)
{
Button btn = new Button();
btn.Text = string.Format("button_{0}", i);
btn.Width = 160;
btn.Height = 50;
if ((i) == 4)
{
btn.Height = 90;
btn.Width = 326;
}
flowLayoutPanel1.Controls.Add(btn);
if ((i) == 3)
{
flowLayoutPanel1.SetFlowBreak(btn, true);
}
}
flowLayoutPanel1.ResumeLayout(true);
}
The problem is the second row too height. enter image description here
the main window is sizeable。