datagridview设置双缓存 实现刷新时页面无闪烁

dgv.SetDoubleBuffered(dgv,true);

 /// <summary>
        /// 将给定的DataGridView设置双缓冲
        /// </summary>
        /// <param name="dgv">给定的DataGridView</param>
        /// <param name="b">设置为ture即打开双缓冲</param>
        public void SetDoubleBuffered(DataGridView dgv, bool b)
        {
            var dgvType = dgv.GetType();
            var pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
            pi.SetValue(dgv, b, null);
        }

posted on 2012-10-25 14:13  酒歌  阅读(597)  评论(0编辑  收藏  举报