SuspendLayout and Multiple Controls

  • Thread starter Thread starter John
  • Start date Start date
J

John

I am looking at ways to reduce the visible delay in a form I have with
many controls. I have two methods that loop across and either enable or
disable all but two of the controls.

I am using SuspendLayout and ResumeLayout at the form level, but so far
I don't see any real improvement because of it. Is there a better way to
handle disabling / enabling large volumes of controls?

I wish I could buffer the form paint surface and have it render off
screen, then just paint the one image after the controls have all
completed their painting.

Thoughts appreciated.
 
John said:
I am looking at ways to reduce the visible delay in a form I have with many
controls. I have two methods that loop across and either enable or disable
all but two of the controls.

I am using SuspendLayout and ResumeLayout at the form level, but so far I
don't see any real improvement because of it. Is there a better way to
handle disabling / enabling large volumes of controls?

'SuspendLayout' will prevent .NET's layouting from occuring. This means
that controls positions and sizes are not recalculated for docked and
anchored controls until 'ResumeLayout' is called. So using 'SuspendLayout'
and 'ResumeLayout' basically makes sense only if you are performing more
than one change. When calling 'ResumeLayout' controls will be repositioned
and resized and thus redrawn.

Preventing controls from redrawing
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=disableredrawing&lang=en>
 
Back
Top