gpt4 book ai didi

c# - 如何在窗体上加倍缓冲 .NET 控件?

转载 作者:IT王子 更新时间:2023-10-29 03:51:20 26 4
gpt4 key购买 nike

如何设置受闪烁影响的窗体控件的 protected DoubleBuffered 属性?

最佳答案

这是一个更通用的版本 Dummy's solution .

我们可以使用反射来获取 protected DoubleBuffered属性,然后可以将其设置为 true

注意:你应该pay your developer taxes而不是 use double-buffering if the user is running in a terminal services session (例如远程桌面)如果此人正在远程桌面中运行,则此辅助方法不会打开双缓冲。

public static void SetDoubleBuffered(System.Windows.Forms.Control c)
{
//Taxes: Remote Desktop Connection and painting
//http://blogs.msdn.com/oldnewthing/archive/2006/01/03/508694.aspx
if (System.Windows.Forms.SystemInformation.TerminalServerSession)
return;

System.Reflection.PropertyInfo aProp =
typeof(System.Windows.Forms.Control).GetProperty(
"DoubleBuffered",
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance);

aProp.SetValue(c, true, null);
}

关于c# - 如何在窗体上加倍缓冲 .NET 控件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76993/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com