I recently had some slowness issues with DataGridView
and the solution was the following code
public static void DoubleBuffered(this DataGridView dgv, bool setting)
{
Type dgvType = dgv.GetType();
PropertyInfo pi = dgvType.GetProperty("DoubleBuffered",
BindingFlags.Instance | BindingFlags.NonPublic);
pi.SetValue(dgv, setting, null);
}
It turns double buffering on for DataGridView
objects. Just call DoubleBuffered()
on your DGV. Hope it helps.
Edit: I might've gotten this off SO, but I can't search for the original right now so this is just to emphasize that the code isn't mine.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…