EKsumic's Blog

let today = new Beginning();

Click the left button to use the catalog.

DE

[解决方案]C#Winform处理由frm.Refresh()方法造成的屏幕闪烁

解决方案

 

在该窗体的构造方法里补充:

 this.DoubleBuffered = true;    //设置本窗体

或者:

SetStyle(ControlStyles.UserPaint, true);

SetStyle(ControlStyles.AllPaintingInWmPaint, true);     // 禁止擦除背景.

SetStyle(ControlStyles.DoubleBuffer, true);     // 双缓冲

 

为什么会闪烁?

对于大多数应用程序,.NET Framework 提供的默认双缓冲将提供最佳效果。默认情况下,标准 Windows 窗体控件是双缓冲的。可以通过两种方法对窗体和所创作的控件启用默认双缓冲。

 

参考文档:

[1] C#Winform频繁刷新导致界面闪烁解决方法

This article was last edited at 2020-03-20 02:36:05

* *