Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to eliminate flicker in Windows.Forms custom control when scrolling?

I want to create a custom control in C#. But every time I have to fully redraw my control, it flickers, even if I use double buffering (drawing to an Image first, and blitting that).

How do I eliminate flicker when I have to fully redraw?

like image 521
user7305 Avatar asked Sep 15 '08 16:09

user7305


1 Answers

You could try putting the following in your constructor after the InitiliseComponent call.

SetStyle(ControlStyles.OptimizedDoubleBuffer | 
         ControlStyles.UserPaint |
         ControlStyles.AllPaintingInWmPaint, true);

EDIT:

If you're giving this a go, if you can, remove your own double buffering code and just have the control draw itself in response to the appropriate virtual methods being called.

like image 107
Shaun Austin Avatar answered Sep 19 '22 16:09

Shaun Austin