[解决方案]C#Winform处理由frm.Refresh()方法造成的屏幕闪烁
Copyright Notice: This article is an original work licensed under the CC 4.0 BY-NC-ND license.
If you wish to repost this article, please include the original source link and this copyright notice.
Source link: https://v2know.com/article/208
解决方案
在该窗体的构造方法里补充:
this.DoubleBuffered = true; //设置本窗体
或者:
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
为什么会闪烁?
对于大多数应用程序,.NET Framework 提供的默认双缓冲将提供最佳效果。默认情况下,标准 Windows 窗体控件是双缓冲的。可以通过两种方法对窗体和所创作的控件启用默认双缓冲。
参考文档:
This article was last edited at 2020-03-19 17:36:05