C# DataGridView 小数据量 高刷新速度场景
- 打开DataGridView所在窗体的双缓冲
- 通过反射设置 DataGridView的双缓冲
代码设置如下:可以放在窗体的构造函数里
//设置窗体的双缓冲
this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
this.UpdateStyles();
//利用反射设置DataGridView的双缓冲
Type dgvType = this.DetailsGrid.GetType();
PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
pi.SetValue(this.DetailsGrid, true, null);