Files
Test/WinFormsApp1/FastDataGridView.cs
2025-09-04 11:25:09 +08:00

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);
}
}