I usually use a little modified version of ngLink's answer.
public class MyControl : Control
{
private int suspendCounter = 0;
private void SuspendDrawing()
{
if(suspendCounter == 0)
SendMessage(this.Handle, WM_SETREDRAW, false, 0);
suspendCounter++;
}
private void ResumeDrawing()
{
suspendCounter--;
if(suspendCounter == 0)
{
SendMessage(this.Handle, WM_SETREDRAW, true, 0);
this.Refresh();
}
}
}
This allows suspend/resume calls to be nested. You must make sure to match each SuspendDrawing
with a ResumeDrawing
. Hence, it wouldn't probably be a good idea to make them public.