Update in each row very slow: ideas ?

Dec 22, 2009 at 6:37 AM


I've make a file editor with this grid and for some functions I've to update each row, for example the first column contains the row ID/number and of course if a row is inserted or removed, I've to recreate/update the IDs.

And if my grid is relatively big (> 5000 rows) I find this slow.

I'v tried several thinks like SuspenLayout/ResumeLayout or thought about multi-threading to allow the user to do something else during this time, but it concerns GUI an so a separate thread doesn't work. And I'm not an algorithm optimization expert.
 think it's a refreshing problem, but for example setting the grid invisible, making the update and then visible introduces a flashing effect and it isn't very faster.

So do you have so ideas/tips for me?


Dec 22, 2009 at 6:34 PM

Well, i am not sure what is exactly causing the slowness. It might one of the several problems.

First thing is that for large number of rows you should use DataGrid, not Grid.  In this case, it should be very fast to insert / remove rows from the datatable, and then bind it to the grid.

Maybe you have a problem, that if you insert a new ID, then you have to loop through ALL other rows, and assign a new ID. if you have this kind of algorithm, then it will not scale.

Dec 23, 2009 at 7:33 AM

Thanks for the advice.

I currently don't use DataGrid and I probably will have to study this thing. I hope I won't have to make too many changes (data edit, events...).

When I insert or remove a row, it's as you say, I have to look in each row, because I have to update the first column which is like in Excel/OpenOffice: it's a rowHeader containing the row number, which has to be updated...


Dec 28, 2009 at 12:39 PM

So yes, use a DataGrid because your grid will simply die when you will have 1 million rows :)