最近看到一些 winform 控件的写法里面,在设定 DockStyle 或者增减子控件的时候,往往先调用 SuspendLayout 方法,操作完毕之后调用一下 ResumeLayout. 不太明白其中的道理。所以用 Reflector 来看一下。
代码在 System.Windows.Forms.Control 中。
做一个简单的记录如下:
public
void
SuspendLayout()
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
this.layoutSuspendCount = (byte) (this.layoutSuspendCount + 1);
}
![](/Images/OutliningIndicators/None.gif)
public
void
ResumeLayout()
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
this.ResumeLayout(true);
}
![](/Images/OutliningIndicators/None.gif)
public
void
ResumeLayout(
bool
performLayout)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
代码在 System.Windows.Forms.Control 中。
做一个简单的记录如下:
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](/Images/dot.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](/Images/dot.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](/Images/dot.gif)