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.

Comments

One response to “Avoid flickering in dynamically rendered control in Windows App”

  1. Windows Programmers Avatar

    Good tip. Flickering is quite a bothersome issue indeed in windows application programming.

Leave a comment