代码之家  ›  专栏  ›  技术社区  ›  daniel

添加控件时锁定winforms UI[重复]

  •  1
  • daniel  · 技术社区  · 7 年前

    我动态地删除和添加了很多控件到表单中。我怎么能只重新绘制一次GUI?

    1 回复  |  直到 7 年前
        1
  •  2
  •   msmolcic    7 年前

    如果要在代码中创建元素,可能需要使用 SuspendLayout 的功能 Form

    this.SuspendLayout();
    
    // Bulk add the elements to the Form controls.
    
    this.ResumeLayout();
    

    documentation :

    控件的布局逻辑将暂停,直到调用ResumeLayout方法。