Files
Test/WinFormsApp1/FastDataGridView.cs
liang123456a 1878f24679 aa
2025-09-04 11:27:18 +08:00

19 lines
589 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);
}
}