Hi,
As far as I know there is no good way to express this in Windows.Forms with FlowLayoutPanel because normal "DockStyle.Top" won't work.
so here is a possible example solution:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
master.Dock = DockStyle.Fill;
master.SizeChanged += Master_SizeChanged;
this.Controls.Add(master);
m_iWidth = master.Width;
Gennerate96FL(96);
}
private void Master_SizeChanged(object sender, EventArgs e)
{
if(m_iWidth != master.Width)
{
m_iWidth = master.Width;
foreach (FlowLayoutPanel flp in listFl96)
flp.Width = m_iWidth;
}
}
int m_iWidth;
FlowLayoutPanel master = new FlowLayoutPanel();
private List<FlowLayoutPanel> listFl96 = new List<FlowLayoutPanel>();
private void Gennerate96FL(int total96)
{
master.Controls.Clear();
listFl96.Clear();
for (int i = 1, loopTo = total96; i <= loopTo; i++)
{
var fl = new FlowLayoutPanel();
fl.Name = $"fl96{i}";
fl.Height = 30;
fl.BackColor = Color.Cornsilk;
fl.BorderStyle = BorderStyle.FixedSingle;
fl.Cursor = Cursors.Hand;
fl.AutoScroll = true;
fl.Width = m_iWidth;
master.Controls.Add(fl);
listFl96.Add(fl);
}
}
}
So we set the initial Width of the "child" FlowLayoutPanels to the Width of it's parent FlowLayoutPanel (I called it "master"), and to react to any Width-Changes for the "master" FlowLayoutPanel (which then updates the "childs" Width-properties)
Not a nice solution but it works...