且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C#在循环中添加控制面板

更新时间:2021-08-26 02:30:15

代码看起来不错,但可能有以下情况。

The code looks fine but there could be a following situations.

1.您可能只有一个条目在文件中,所以您只会在面板中添加一个按钮。

1.You might have only one entry in the file, so you are experiencing only One Button added to the panel.

2.您的面板宽度小于所有动态按钮宽度的总和

我怀疑没有2是导致问题的主要原因。

I suspect no 2 is the main reason that is causing problem.

所以,我建议您使用 FlowLayoutPanel 。添加动态内容,因为它会自动布局所有子控件。

So, I recommend that you use FlowLayoutPanel. To add a dynamic content as it automatically layout all the child controls.