65.9K
CodeProject is changing. Read more.
Home

Reducing flicker, blinking in DataGridView

starIconstarIconstarIconstarIconstarIcon

5.00/5 (24 votes)

May 23, 2012

CPOL
viewsIcon

76704

Reducing flicker and blinking in DataGridView.

Introduction

One of my project requirement was to create a Output Window similar to Visual Studio. For that I used a DataGridView. But when I start my application, I found that there is lot of blinking, flicker, pulling... After badly hitting my head with Google, I found a very easy way. We just need to create a extension method to DataGridView and it's all done:

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