SuspendLayout and Multiple Controls

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.
 
H

Herfried K. Wagner [MVP]

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top