zoukankan      html  css  js  c++  java
  • Winform ListView 窗体闪烁问题解决

    在 winform 编程时, ListView 添加数据时 控件闪烁 , 参考如下解决方法,得到改善。

    首先,自定义一个类ListViewNF,继承自 System.Windows.Forms.ListView

    代码如下:

     public class ListViewNF : System.Windows.Forms.ListView
        {
            public ListViewNF():base()
            {
                // 开启双缓冲
                this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
    
                // Enable the OnNotifyMessage event so we get a chance to filter out 
                // Windows messages before they get to the form's WndProc
                this.SetStyle(ControlStyles.EnableNotifyMessage, true);
            }
    
            protected override void OnNotifyMessage(Message m)
            {
                //Filter out the WM_ERASEBKGND message
                if (m.Msg != 0x14)
                {
                    base.OnNotifyMessage(m);
                }
    
            }
        }

    然后,修改我们的Form代码中定义ListView的位置,将原来的

    System.Windows.Forms.ListView listView1;

    修改为

    ListViewNF listView1;

    最后大功告成。

    软件界面如下:

    参考:https://www.cnblogs.com/zdkjob/archive/2012/01/17/2324618.html

  • 相关阅读:
    01
    王天宇0703作业
    0706作业
    0705作业
    0704作业
    0703作业
    数据库死锁语句脚本
    项目问题 : 尝试读取或写入受保护的内存。这通常指示其他内存已损坏
    工厂模式(Factory Patter)
    修改DevExpress中英文提示,将英文改为中文
  • 原文地址:https://www.cnblogs.com/howtrace/p/10689171.html
Copyright © 2011-2022 走看看