DataGridView实现双缓冲(转)

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

使用方法:

dgrRealTimeData.SetDoubleBuffered(true); //设置双缓冲

转自:http://www.oschina.net/code/snippet_96699_707 

posted on 2012-03-08 21:50  一路前行  阅读(2292)  评论(0编辑  收藏  举报