Live Chat Icon For mobile
Live Chat Icon

How can I minimize flickering when drawing a control

Platform: WinForms| Category: Drawing Tips

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
		// This call is required by the Windows.Forms Form Designer.

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

		// TODO: Add any initialization after the InitForm call

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.