C#:ResumeLayout(true)是否与ResumeLayout(false)+ PerformLayout()一样?

编程入门 行业动态 更新时间:2024-10-25 08:14:41
本文介绍了C#:ResumeLayout(true)是否与ResumeLayout(false)+ PerformLayout()一样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经查看了生成的Form s和UserControl s设计器代码,在InitializeComponent()方法中,它们始终以

I have looked at the generated designer code of Forms and UserControls, and in the InitializeComponent() method they always start with

this.SuspendLayout();

并以

this.ResumeLayout(false); this.PerformLayout();

但是从我在这些方法的msdn文档中所看到的,并不会以

But from what I can see in the msdn documentation of those methods, wouldn't ending with

this.ResumeLayout(true); // Or just this.ResumeLayout()

完全一样吗?还是我在这里想念东西?

do the exact same thing? Or am I missing something here?

询问,因为我将以另一种方法添加一堆控件,并认为我应该执行suspend-resume例程以使其美观高效.但是无法弄清楚这两个方法调用的原因是什么,当您似乎只能使用一个方法时...

推荐答案

使用反射器:

this.ResumeLayout() is equal to this.ResumeLayout(true)

但是

this.ResumeLayout(true) is not equal to this.ResumeLayout(false) + this.PerformLayout()

原因: 当使用false调用ResumeLayout时,将循环遍历一个控件集合,并且LayoutEngine在布局中的每个控件上调用InitLayout.

Reason: When ResumeLayout is called with false, there is a control collection that is looped through and the LayoutEngine calls InitLayout on each of the controls in the layout.

更多推荐

C#:ResumeLayout(true)是否与ResumeLayout(false)+ PerformLayout()一样?

本文发布于:2023-07-16 23:05:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1126870.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:true   ResumeLayout   PerformLayout   false

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!