挖一下 SuspendLayout, ResumeLayout 的原理
来源:互联网 发布:黑河学院网络管理系统 编辑:程序博客网 时间:2024/05/16 06:24
最近看到一些 winform 控件的写法里面,在设定 DockStyle 或者增减子控件的时候,往往先调用 SuspendLayout 方法,操作完毕之后调用一下 ResumeLayout. 不太明白其中的道理。所以用 Reflector 来看一下。
代码在 System.Windows.Forms.Control 中。
做一个简单的记录如下:
代码在 System.Windows.Forms.Control 中。
做一个简单的记录如下:
public void SuspendLayout()
{
this.layoutSuspendCount = (byte) (this.layoutSuspendCount + 1);
}
public void ResumeLayout()
{
this.ResumeLayout(true);
}
public void ResumeLayout(bool performLayout)
{
if (this.layoutSuspendCount > 0)
{
this.layoutSuspendCount = (byte) (this.layoutSuspendCount - 1);
if (((this.layoutSuspendCount == 0) && ((this.state & 0x200) != 0)) && performLayout)
{
this.PerformLayout();
}
}
if (!performLayout)
{
Control.ControlCollection collection1 = (Control.ControlCollection) this.Properties.GetObject(Control.PropControlsCollection);
if (collection1 != null)
{
for (int num1 = 0; num1 < collection1.Count; num1++)
{
Control.LayoutManager.UpdateAnchorInfo(collection1[num1]);
}
}
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public void PerformLayout()
{
this.PerformLayout(null, null);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public void PerformLayout(Control affectedControl, string affectedProperty)
{
if (!this.GetAnyDisposingInHierarchy())
{
if (this.layoutSuspendCount > 0)
{
this.state |= 0x200;
}
else
{
this.layoutSuspendCount = 1;
try
{
this.OnLayout(new LayoutEventArgs(affectedControl, affectedProperty));
}
finally
{
this.state &= -513;
this.layoutSuspendCount = 0;
}
}
}
}
{
this.layoutSuspendCount = (byte) (this.layoutSuspendCount + 1);
}
public void ResumeLayout()
{
this.ResumeLayout(true);
}
public void ResumeLayout(bool performLayout)
{
if (this.layoutSuspendCount > 0)
{
this.layoutSuspendCount = (byte) (this.layoutSuspendCount - 1);
if (((this.layoutSuspendCount == 0) && ((this.state & 0x200) != 0)) && performLayout)
{
this.PerformLayout();
}
}
if (!performLayout)
{
Control.ControlCollection collection1 = (Control.ControlCollection) this.Properties.GetObject(Control.PropControlsCollection);
if (collection1 != null)
{
for (int num1 = 0; num1 < collection1.Count; num1++)
{
Control.LayoutManager.UpdateAnchorInfo(collection1[num1]);
}
}
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public void PerformLayout()
{
this.PerformLayout(null, null);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public void PerformLayout(Control affectedControl, string affectedProperty)
{
if (!this.GetAnyDisposingInHierarchy())
{
if (this.layoutSuspendCount > 0)
{
this.state |= 0x200;
}
else
{
this.layoutSuspendCount = 1;
try
{
this.OnLayout(new LayoutEventArgs(affectedControl, affectedProperty));
}
finally
{
this.state &= -513;
this.layoutSuspendCount = 0;
}
}
}
}
- 挖一下 SuspendLayout, ResumeLayout 的原理
- 对WinForm-SuspendLayout、ResumeLayout、PerformLayout的理解
- SuspendLayout 和 ResumeLayout 方法
- SuspendLayout 和 ResumeLayout
- C# SuspendLayout()和ResumeLayout()
- WinForm-SuspendLayout、ResumeLayout、PerformLayou
- WinForm-SuspendLayout、ResumeLayout、PerformLayou
- 使用SuspendLayout和ResumeLayout
- ResumeLayout、SuspendLayout、PerformLayout
- 使用SuspendLayout和ResumeLayout
- WinForm 中 Control.SuspendLayout, Control.ResumeLayout, PerformLayout 之间的关系
- suspendlayout,resumelayout,layout,performlayout【转】
- suspendlayout,resumelayout,layout,performlayout【转】
- Control.SuspendLayout 方法 ResumeLayout 方法 (Boolean)
- C# WinForm中的SuspendLayout、ResumeLayout、PerformLayou
- WinForm-SuspendLayout、ResumeLayout、PerformLayou——转载
- WinForm-SuspendLayout、ResumeLayout、PerformLayou——转载
- 利用SuspendLayout 和 ResumeLayout 方法加速添加控件
- 建议博客园增加 blog 内容的 zip 打包功能。
- 用 C# 分析 URL 中的参数信息
- 我的 blog 换肤了,顺便修改了几个默认样式
- 没事练习一下算法:全排列的递归算法。
- 在 Microsoft Virtual PC 2004 中运行 vs.net 2003 的配置问题
- 挖一下 SuspendLayout, ResumeLayout 的原理
- asp.net 包含动态创建控件的容器如果要切换显示/隐藏不要用 Visible 属性
- VBScript 中的 Empty, Null, "" 讨论
- 今天无意中又发现一个记事本的 bug
- 服务器控件是否必须在 runat=server 的 Form 内?
- Master Page 的原理分析, IParserAccessor.AddParsedSubObject 方法
- 开始新生活!
- 感觉 Data Access Application Block(DAAB) 里也有可能写得不太好的地方
- 执行存储过程的多种写法