Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Reducing flicker, blinking in DataGridView

5.00/5 (25 votes)
23 May 2012CPOL 76.7K  
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:

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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)