Avoid flickering in dynamically rendered control in Windows App

Here is a tip shared by Kannan, a colleague of mine on how to avoid flickering when rendering controls dynamically in a Windows Application.

Enable double buffering, so that the flickering does not happen.

Add the following after the ‘InitializeComponent’ method.

      SetStyle(ControlStyles.UserPaint, true);
      SetStyle(ControlStyles.AllPaintingInWmPaint, true);
      SetStyle(ControlStyles.DoubleBuffer, true);

That’s it.

Advertisements

One thought on “Avoid flickering in dynamically rendered control in Windows App

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s