I need to build and display a huge data grid (roughly 5000x5000). (I know it
is difficult to view, but i need to do it anyway)
the immediate problem i am facing is that it takes a VERY long time to add
5000 columns. i created an array of DataGridViewTextBoxColumn[] and called
DataGridView Columns.AddRange(array). This still takes a VERY long time. i
haven't even attempted to add the 5000 rows or calculate the values of each
cell (25M of them)
is there a trick that i am overlooking on how to manage this?
But there must be a better way. it makes more sense to display the headers
and rows and calculate the value of the cells as they become visible rather
doing the whole thing up front. is there a way to do this? or do i need to
use a third party product?
thanks
m
Bob Powell [MVP] - 17 Sep 2007 18:32 GMT
Are you databinding this huge array in some way? Perhaps a virtual grid
approach may be more useful.

Signature
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
>I need to build and display a huge data grid (roughly 5000x5000). (I know
>it is difficult to view, but i need to do it anyway)
[quoted text clipped - 14 lines]
> thanks
> m
Nicholas Paldino [.NET/C# MVP] - 17 Sep 2007 18:45 GMT
You can virtualize the grid, setting the VirtualMode property to true.
However, it won't allow you to virtualize the columns, just the rows. Take
a look at the section titled "Virtual Mode in the Windows Forms DataGridView
Control", located at:
http://msdn2.microsoft.com/en-us/library/ms171622.aspx
I would recommend giving the user a choice as to what columns they can
see. With all due respect, there is absolutely no way that anyone can make
sense of 5000 columns in a grid, and there is absolutely no reason to
display them all. It's insane to do so. It is only going to serve to be
confusing, as well as a tremendous resource drain.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
>I need to build and display a huge data grid (roughly 5000x5000). (I know
>it is difficult to view, but i need to do it anyway)
[quoted text clipped - 14 lines]
> thanks
> m
Larry Smith - 17 Sep 2007 18:54 GMT
>I need to build and display a huge data grid (roughly 5000x5000). (I know
>it is difficult to view, but i need to do it anyway)
[quoted text clipped - 11 lines]
> rather doing the whole thing up front. is there a way to do this? or do i
> need to use a third party product?
The number of columns you're dealing with is completely unreasonable IMO (do
you really "need" to do it) but in any case, you can check out its
"VirtualMode" property though it doesn't address the number of columns
(which you should handle dynamically anyway). IMO however, you may wish to
consider a 3rd-party product instead. I normally hate to resort to this
since I generally distrust most products on the market outside of MSFT.
However, the "DataGridView" has been an enormous source of problems for me
personally after more than a year of very intense work with it (and a lot of
research into improving its performance - note that even one MSFT blogger
acknowledged the problem based on the use of slower API functions compared
to the older "DataGrid" control - perhaps you should check that control out
instead though I've never used it myself). In any case, the performance can
be very, very poor as you've now discovered (depending on various factors)
but moreover, there are some (potentially) difficult programming issues with
the control in general depending on what you're up to (which I won't get
into here). MSFT no doubt spent a lot of time designing this control and it
certainly shows. It has a lot of power and flexibility but there are still
some serious issues that need to be worked out IMO (performance being a
major one).