19 lines
579 B
C#
19 lines
579 B
C#
using System;
|
|
using System.Reflection;
|
|
using System.Windows.Forms;
|
|
|
|
public class FastDataGridView : DataGridView
|
|
{
|
|
public FastDataGridView()
|
|
{
|
|
// 通过反射开启 DataGridView 的 DoubleBuffered 属性
|
|
typeof(DataGridView)
|
|
.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic)
|
|
.SetValue(this, true, null);
|
|
|
|
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
|
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
|
this.SetStyle(ControlStyles.UserPaint, true);
|
|
}
|
|
}
|