Click here to Skip to main content
14,388,768 members
Rate this:
Please Sign up or sign in to vote.
See more:
Ok so I have a DataGridView that contains columns one of them being a DataGridViewImageColumn. But when I open the form containing the docked DataGridView it takes a long time to load.

My first solution was to set the DataGridView to VirtualMode and although there was a major improvement on the speed the form takes to load (now the form loads instantly but you can see the DataGridView creating the cells one by one).

Is there anyway to speed up the time it takes the DataGridView to load?

P.S.

In the CellValueNeeded Event of the VirtualMode DataGridView I timed the time it takes to create a DataGridViewTextBoxColumn ( 00 : 00 : 00) and DataGridViewImageColumn (00 : 00 : 00.0468001)

I get my images from the resource folder in the C# project and each image has dimensions 23x23.

Little more background...
What I have is 5 difference images. Each referring to a difference status on the item currently defined in the row. I will always use one of these images and never in the maintenance of the program plan to include more than 5 images or less than these 5 images.

Progress... Instead of getting the images from the resources folder every time I have declared 5 Image objects and I am using then as the images. The time now is as follows to create the cells...a DataGridViewTextBoxColumn ( 00 : 00 : 00) and DataGridViewImageColumn (00 : 00 : 00.0370001)
Posted
Updated 14-Oct-12 23:15pm
v4
Comments
Dave963 15-Oct-12 3:56am
   
I get my images from the resources folder in the c# project and also each images has a dimension of about 23x23
Rate this:
Please Sign up or sign in to vote.

Solution 1

That depends on your data. You really can't speed up the generation and rendering of the rows and columns themselves.

But, if you're getting images out of the database that a huge and rendering them in a small area, you're wasting time because you're processing a lot of image data you're not using.

For example, your image column is showing images in 100x50 pixels, but the images you're getting from your database are 5000x2500, you're wasting a lot of time transferring and rendering data and you're not using.

The solution to that is simple. Add another column to your database that has "thumbnail" copies of your images in it that your grid can use without all the extra overhead.
   
Comments
Dave963 15-Oct-12 3:56am
   
I get my images from the resources folder in the c# project and also each images has a dimension of about 23x23
Dave Kreskowiak 15-Oct-12 7:43am
   
If you're not loading tons of images, there's nothing you can do to speed it up.
Rate this:
Please Sign up or sign in to vote.

Solution 2

I forgot about this post but just to finally marked it as solve I will say the following. For some of the data that I displayed I had to do some calculations with the data, and do to a poorly written alogrithm, that slowed down my load time on the datagridview. So after rewriting the algorithm it worked perfectly. Thank for everyones input, much appreciatted.
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100