首页 > Windows开发 > 详细

Winfrom 减少控件重绘闪烁的方法

时间:2020-02-24 10:03:37      阅读:73      评论:0      收藏:0      [点我收藏+]
  1. Winform控件的双缓冲。控件的双缓冲属性是隐藏的,可以通过反射改变其属性值。
    lv.GetType().GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(lv, true, null);
    //lv为控件名称

     

  2. 重绘控件的时候开启控件双缓冲。
    this.SetStyle(ControlStyles.DoubleBuffer | 
    
          ControlStyles.UserPaint | 
          ControlStyles.AllPaintingInWmPaint,
          true);
    this.UpdateStyles();

     

  3. 通过消息,禁用掉清除背景的消息。(TreeView控件实用)
    protected override void WndProc(ref Message m)
      {
          if (m.Msg == 0x0014) // 禁掉清除背景消息
              return;
          base.WndProc(ref m);
      }

     

Winfrom 减少控件重绘闪烁的方法

原文:https://www.cnblogs.com/yincq/p/12355563.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!