Strange empty spaces in FlowLayoutPanel

穿精又带淫゛_ 提交于 2019-12-01 17:33:00
darx

Thank you Hans! I thinks this is a real answer, as it solved my problem: (quote from comments)

It is a bug, same one as this one. The extra space is the height of the next label. The workaround is exactly the same, just add a dummy control with a Width of 0 after the label. – Hans Passant

So first I removed flowbreak after the real label:

flowLayoutPanel1.SetFlowBreak(label, true);

And then replaced it with the following code, and the mysterious space disappeared!

Label dummyLabel = new Label();
dummyLabel.Width = 0;
dummyLabel.Height = 0;
dummyLabel.Margin = new Padding(0, 0, 0, 0);

flowLayoutPanel1.Controls.Add(dummyLabel);
flowLayoutPanel1.SetFlowBreak(dummyLabel, true);

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!