解决C#中ListView控件动态添加项时闪屏的问题

解决原理:重载ListView控件,让控件支持Double Buffer。

重载的Double Buffer类代码如下:
    /// <summary>
    /// This override list view support double buffer to avoid the twinkling when insert a new item dynamically
    /// </summary>
    public class DoubleBufferListView : ListView
    {
        public DoubleBufferListView()
        {
            SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
            UpdateStyles();
        }
    }
 

摘自:http://www.wewill.cn/n21083c67.aspx

Tags:

Leave a Reply