how to stop flickering C# winforms

For a “cleaner solution” and in order to keep using the base Panel, you could simply use Reflection to implement the double buffering, by adding this code to the form that holds the panels in which you want to draw in

    typeof(Panel).InvokeMember("DoubleBuffered", 
    BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic, 
    null, DrawingPanel, new object[] { true });

Where “DrawingPanel” is the name of the panel that you want to do the double buffering.

I know quite a lot of time has passed since the question was asked, but this might help somebody in the future.

Leave a Comment