how to stop flickering C# winforms

前端 未结 16 2386
故里飘歌
故里飘歌 2020-11-28 04:16

I have a program that is essentially like a paint application. However, my program has some flickering issues. I have the following line in my code (which should get rid of

16条回答
  •  忘掉有多难
    2020-11-28 04:50

    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.

提交回复
热议问题