zoukankan
html css js c++ java
挖一下 SuspendLayout, ResumeLayout 的原理
最近看到一些 winform 控件的写法里面,在设定 DockStyle 或者增减子控件的时候,往往先调用 SuspendLayout 方法,操作完毕之后调用一下 ResumeLayout. 不太明白其中的道理。所以用 Reflector 来看一下。
代码在 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
;
}
}
}
}
查看全文
相关阅读:
python 文件操作
高级函数
运行cadence dpi例子出现的问题
我对验证的一些理解【zz】
archlinux 下挂载ntfs分区,显示"permission denied"
vs2012安装SharePoint 2013的项目模版
Iptables工具的使用
webmin简介
cassandra简介
linux中端口扫描
原文地址:https://www.cnblogs.com/RChen/p/161379.html
最新文章
String.Equals
Perl — 字符串与排序
QuickSortSplit
Web服务
WordsCount
接口&抽象类
C++ const function
System.Collections命名空间
ASP.NET 回送
TFS2010 取消锁定
热门文章
WINFORM 请求“System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”类型的权限已失败。
Ext.Net GridPanel中式排序
Dotfuscator for Windows Phone7
手机上显示E、G、T、H代表什么意思
TFS 路径...已在工作区...
数据库优化设计方案
数据库附加失败及附加后只读的解决办法
Linux命令:cp (copy)复制文件或目录
第一个应用 Hello Android
Python之路,Day1 Python基础1 介绍、基本语法、流程控制
Copyright © 2011-2022 走看看