How to prevent DataGridView from flickering when scrolling horizontally?

use this class

public static class ExtensionMethods
{
   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);
   }
}

and enter this code.

this.dataGridView1.DoubleBuffered(true);

enjoy.

Leave a Comment