Thursday, August 26, 2010

Slow Datagridview... Oh No!

So we all have been here, I had finished a project using VS2008, implementing  Datagridviews on litterally each and every form of the system. This had been a requirement from the onset as to ensure easy searching,navigation and capturing of data. So the data capture ladies start doing their thing and low and behold the dreaded call... they are unhappy with the speed of the DataGridView. I had to agree with them, the repaint of the and overall perfromance of the grid is awfull. So started a tedious process of trying to speed this up...

The first step was to look at my queries but they seemed fine. Not a lot I could do there.

I tried removing gridlines and embbed smaller images... really clutching at straws... could not get the speed up to acceptable levels.

All the while having users getting more and more irate with the performance.  

Here is what it looked like :

As you can see... a straight select of +-6000 rows got the grid choking to a repaint of more than 5 seconds!!

Anyway... after a lot of soul searching and delving deep a finally got to the solution. The same grid now loads/repaints in less than a second... here's what it looks like after my efforts

I wrote the solution into a DDL .. so just add the dll as a reference to your project like this.....

Then in your Form_Load event you just call  YourGridviewName.SpeedUpThisGridView(true);

and there you are.

This implemetation will sort out all your DataGridView speed issues. I wrote this in VS2008 and tested it in VS2010. Please note that this dll is only for Win APP's and not for Web or SilverLight

Works like a dream, with a lot of happy customers.

If you want a copy of this dll please email me at and I will send it to you ASAP.