I need to add a lot of controls to a parent control.
But I find if I add ParentControl.SuspendLayout
and ParentControl.ResumeLayout
before and after I add those controls to the parent, I use stopwatch to measure the ticks:
If I remove the code ParentControl.SuspendLayout
and ParentControl.ResumeLayout
, it will be faster. Why does it happen?
So SuspendLayout
and ResumeLayout
are not supposed to reduce the time to add sub controls, right? So what's the benefit to use SuspendLayout
and ResumeLayout
or in other words, if I don't use SuspendLayout
and ResumeLayout
but add the sub controls directly to parents, what's the bad?