DataGridView takes very much time if I update a lot of data
I have a DataGridView which has a DataSource (a DataTable) of 3000
rows. If I want to update one column of every rows in the DataTable,
my whole appliation freezes with any response. After a lot of time, it
comes back.
If I set the DataSource to null before changing the data and set it
back after changing. There' s no problem. But I lost the status of the
DataGridView, like current selected row, sorting, etc.
Is there any way to prevent the DataGridView to do anything while I am
updating the data in the DataTable?
Boaz Ben-Porat - 11 Oct 2007 21:54 GMT
Have you tried dataGridView1.SuspendLayout () ?
I haven't tried it myself, but i think it works.
Boaz Ben-Porat
Milestone systems A/S
Denmark
> DataGridView takes very much time if I update a lot of data
>
[quoted text clipped - 9 lines]
> Is there any way to prevent the DataGridView to do anything while I am
> updating the data in the DataTable?
hjin - 12 Oct 2007 14:21 GMT
I tried SuspendLayout and SuspendBinding. All didn't work.
Finally I found because I set all columns' AutoSize to AllCells,
everytime I changes a value in one cell, it goes through all the cells
in the column to recaculate the column's width. I think it's a bad
code because it already knows the preivous width and it should only
caculate the width of the changed cell. I have to set the columns'
AutoSize to None before changing the data and set them back to
AllCells afterwards.