简体   繁体   English

向嵌套面板添加控件的顺序是否正确?

[英]Is there a proper order in which to add controls to nested panels?

I have odd drawing of Controls within FlowLayoutPanels happening when I change the order of when the Controls are added to the FlowLayoutPanels and when those panels are added to a main panel. 当我更改将Controls添加到FlowLayoutPanels的顺序以及将这些面板添加到主面板时的顺序时,会在FlowLayoutPanels发生Controls奇怪绘制。

Specifically, I have groups of Controls I wish to show together. 具体来说,我希望将一组Controls一起展示。 I add the Controls in a group to a FlowLayoutPanel and add all of these panels to a main FlowLayoutPanel . 我将一个组中的Controls添加到FlowLayoutPanel ,并将所有这些面板添加到主FlowLayoutPanel Now, if if I add the child FlowLayoutPanels to the main ( mainPanel.Controls.Add(childPanel) ) before adding the Controls to the child, the Controls are drawn properly. 现在,如果在将Controls添加到子mainPanel.Controls.Add(childPanel)之前将子FlowLayoutPanels添加到主mainPanel.Controls.Add(childPanel)mainPanel.Controls.Add(childPanel) ),则Controls将正确绘制。 If I add all of the Controls to the child FlowLayoutPanel then add the panel to the main panel, all of the Controls are drawn in-properly. 如果我将所有Controls都添加到子FlowLayoutPanel然后将面板添加到主面板中,则所有Controls的绘制都会不正确。

It will not glitch if you first call SuspendLayout : 如果您首先调用SuspendLayout ,它将不会出现故障:

this.SuspendLayout();

// ... add controls

this.ResumeLayout();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM