如何使用C#(Windows窗体)启用控件的双缓冲?

如何使用C#(Windows窗体)启用控件的双缓冲?

我有一个面板控件,我正在绘制内容,也是一个所有者绘制的选项卡控件。 两者都有闪烁,所以如何启用双缓冲?

在控件的构造函数中,适当地设置DoubleBuffered属性和/或ControlStyle。

例如,我有一个简单的DoubleBufferedPanel,其构造函数如下:

this.DoubleBuffered = true; this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.ContainerControl | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor , true); 

一些信息在这里:

如何在表单上双重缓冲.NET控件?

使用inheritance自System.Windows.Forms.Control的DoubleBuffered属性。

 System.Windows.Forms.Form myForm = new System.Windows.forms.Form(); myForm.DoubleBuffered = true;