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程序设计--第6章 面向对象编程
Python程序设计--第5章 函数设计与使用
Python程序设计--第4章 字符串与正则表达式
Python程序设计--第3章 选择与循环
Python程序设计--第2章 python序列
Python程序设计--第1章 基础知识
Python基本计算--除法
ES6:对象新增方法
ES6:字符串常用方法
ES6:let和const用法
原文地址:https://www.cnblogs.com/RChen/p/161379.html
最新文章
图解HTTP
图解TCP_IP
30-Day Leetcoding Challenge Day15
30-Day Leetcoding Challenge Day14
30-Day Leetcoding Challenge Day13
30-Day Leetcoding Challenge Day12
30-Day Leetcoding Challenge Day10
leetcode104,111,543 求二叉树深度的dfs解法
dvwa学习笔记之xss
access和MySQL mssql
热门文章
黑客攻防web安全实战详解笔记
jvm 获取linux的时区与系统不一致
将mongo查出的document转换为对象
mongo集群误删admin,如何操作
mongo分片后 ,数据只存在一个shard中
MongoDB 认证遇到的坑
MongeDb分片命令
Python字符串函数示例
Python字符串函数示例
Python程序设计--第7章 文件操作
Copyright © 2011-2022 走看看