如何滚动时消除闪烁Windows.Forms的中自定义的控制?自定义、Windows、Forms

2023-09-02 21:29:28 作者:我比葡萄淘

我要创建在C#中的自定义控制。但每次我都完全重绘我的控制,它闪烁,即使我使用双缓冲(画上一个形象第一,和块传输的)。

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?

推荐答案

您可以尝试把在InitiliseComponent通话后你的构造如下。

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

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

编辑:

如果你给这个一展身手,如果可以,删除自己的双缓冲code,只是有控制绘制自身应对被称为相应的虚拟方法。

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.

 
精彩推荐