Microsoft Communities

Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do I minimize flickering when drawing a control?

The Window.Forms framework offers support for double buffering to avoid flickers through ControlStyles. Double buffering is a technique that attempts to reduce flicker by doing all the drawing operations on an off-screen canvas, and then exposing this canvas all at once. To turn on a control's double buffering, you need to set three styles.

public UserPictureBox() //derived from System.Windows.Forms.Control 
{ 
  InitializeComponent(); 

// Activates double buffering 
  SetStyle( ControlStyles.UserPaint, true ); 
  SetStyle( ControlStyles.AllPaintingInWmPaint, true ); 
SetStyle( ControlStyles.DoubleBuffer, true ); 
} 

Contributed from George Shepherd's Windows Forms FAQ



Page view counter