如何在窗体上双缓冲.NET控件? [英] How to double buffer .NET controls on a form?

查看:212
本文介绍了如何在窗体上双缓冲.NET控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置保护 DoubleBuffered 这是从闪烁遭受窗体上的控件的属性?

How can I set the protected DoubleBuffered property of the controls on a form that are suffering from flicker?

推荐答案

下面是<一个更宽泛的版本href=\"http://stackoverflow.com/questions/76993/how-to-double-buffer-net-controls-on-a-form#77041\">Dummy's解决方案。

我们可以使用反射来获得在受保护的DoubleBuffered属性,那么它可以被设置为真正

We can use reflection to get at the protected DoubleBuffered property, and then it can be set to true.

注意:您应该支付开发商税,而不是使用双缓冲在终端服务会话(如远程桌面)如该人在远程桌面运行这个辅助方法不会在双重缓冲开启。

Note: You should pay your developer taxes and not use double-buffering if the user is running in a terminal services session (e.g. Remote Desktop) This helper method will not turn on double buffering if the person is running in remote desktop.

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); 
}

这篇关于如何在窗体上双缓冲.NET控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆