suspendlayout(C# SuspendLayout和ResumeLayout「终于解决」)

发布时间:2025-12-10 19:21:16 浏览次数:8

C# SuspendLayout和ResumeLayout「终于解决」-suspendlayout窗体上控件不能编辑 c#

C# SuspendLayout()和ResumeLayout()「终于解决」Temporarilysuspendsthelayoutlogicforthecontrol.Namespace:  System.Windows.FormsAssembly:  System.Windows.Forms (inSystem.Windows.Forms.dll)SyntaxC#C++

Temporarily suspends the layout logic for the control.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll) Syntax
C# C++ F# VB
publicvoidSuspendLayout()

是否还在为Ide开发工具频繁失效而烦恼,来吧关注以下公众号获取最新激活方式。亲测可用!

为防止网络爬虫,请关注公众号回复”口令”

激活idea 激活CLion DataGrip DataSpell dotCover dotMemory dotTrace GoLand PhpStorm PyCharm ReSharper ReShaC++ Rider RubyMine WebStorm 全家桶 刷新

【正版授权,激活自己账号】:Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】:官方授权 正版激活 自己使用,支持Jetbrains家族下所有IDE…

Remarks

The layout logic of the control is suspended until theResumeLayoutmethod is called.

TheSuspendLayoutandResumeLayoutmethods are used in tandem to suppress multipleLayoutevents while you adjust multiple attributes of the control. For example, you would typically call theSuspendLayoutmethod, then set theSize,Location,Anchor, orDockproperties of the control, and then call theResumeLayoutmethod to enable the changes to take effect.

There must be no pending calls toSuspendLayoutforResumeLayoutto be successfully called.

Note

When adding several controls to a parent control, it is recommended that you call theSuspendLayoutmethod before initializing the controls to be added. After adding the controls to the parent control, call theResumeLayoutmethod. This will increase the performance of applications with many controls.

Examples

The following code example adds two buttons to a form. The example transactions the addition of the buttons by using theSuspendLayoutandResumeLayoutmethods.

C# C++ VB
privatevoid AddButtons(){   // Suspend the form layout and add two buttons.   this.SuspendLayout();   Button buttonOK = new Button();   buttonOK.Location = new Point(10, 10);   buttonOK.Size = new Size(75, 25);   buttonOK.Text = "OK";   Button buttonCancel = new Button();   buttonCancel.Location = new Point(90, 10);   buttonCancel.Size = new Size(75, 25);   buttonCancel.Text = "Cancel";   this.Controls.AddRange(new Control[]{buttonOK, buttonCancel});   this.ResumeLayout();}
需要做网站?需要网络推广?欢迎咨询客户经理 13272073477