How to improve painting performance of DataGridView?

后端 未结 6 827
别那么骄傲
别那么骄傲 2020-12-01 12:40

(sorry for bad English)

I have a big problem with performance of DataGridView when it re-paints.

I\'m using a DataGridVie

6条回答
  •  既然无缘
    2020-12-01 13:24

    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.

提交回复
热议问题