Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Speeding up setting of DataGridView.RowCount

$
0
0
I'm having an issue with a datagridview running in virtual mode.

The DataGridView itself runs in VirtualMode has 6 set columns.  The ammount of data returned could be very large (250k rows). 

The slow code is this:

gvPartSearch.SuspendLayout();
gvPartSearch.RowCount = _memoryCache.NumberOfRows;
gvPartSearch.ResumeLayout();

If the numberofrows is ~25000, it takes around a second and a half to run the above.  If it is 250,000, it takes roughly 16 seconds (so at least it is pretty linear).

We rewrote the application in C# (it use to be in C++ using WTL) and were able to do this (or rather a similar action using a CListViewCtrl with an attached List Control) in WTL much faster.

So is there any tricks to making the setting of RowCount go faster?

Edited to add:

I mentioned this to a co-worker and he suggested I thread out the work.  Seems to have worked, I'm not sure why though as the thread had to invoke a delegate in the thread that controls the datagridview (which I would have assumed would have been the same as setting the RowCount in the way I was doing before, but it apparently is not).  I can now adjust to 1.78 million rows in about 3.5 seconds.

Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>