当我使用代码在flowLayoutPanel中自动创建面板时,它在flowLayoutPanel1中创建了额外的空间,我不知道如何删除它。
VS2019 .NET Framework 4.7.2
flowLayoutPanel1.Width = ClientRectangle.Width;
Random R = new Random();
Console.WriteLine(flowLayoutPanel1.Width);
int div = 4;
for(int i=0;i< div; i++)
{
Panel p = new Panel();
p.Name = "";
p.BackColor = Color.FromArgb(123, R.Next(222), R.Next(222));
p.Size = new Size(flowLayoutPanel1.Width / div, flowLayoutPanel1.Height);
Console.WriteLine(flowLayoutPanel1.Width / div);
flowLayoutPanel1.Controls.Add(p);
}
我希望它将在flowLayoutPanel1中显示4个面板,但是它只会在flowLayoutPanel1中创建3个面板和额外的空间。