I found that UltraGrid is very slow to refresh after i make changes to the attached UltraDataSource. I followed Mike's article about UltraGrid's performance and added
this.ultraGrid1.BeginUpdate();this.ultraGrid1.SuspendRowSynchronization();
and corresponding Resume and EndUpdate functions but that didn't improve matters much. After some experimenting I got reasonable performance if I just set DataSource of my grid to NULL, do changes to data source and then assign my data source back to grid.
I just think I'm missing something here.
What kind of changes are you making?
Any time you make a change to the data source, like adding, deleting, or editing rows, the data source notifies the grid of the change and the grid responds. So if you make a lot of changes all at once, it can be a performance issue.
BeginUpdate tells the grid not to paint, so that will help improve performance.
SuspendRowSynchronization tells the grid not to synchronize the rows, so that will help some more.
But there is still some processing going on in the grid. So if those methods don't help, then we'd have to know exactly exactly what you are doing to the data source and consequently what notifications the grid is getting so we could see why the grid is slow.
If you can duplicate the problem in a small sample project, we could check it out and maybe improve the performance or give you tips on how you can make it faster.
Hi,
I am calling "grid.UpdateData()" method after modifying data from code behind. It is taking too much time. My code as below:
for (int i = 0; i < grid.Rows.Count; i++){ UltraGridRow row = this.Rows[i]; row.Cells[this.ActiveCell.Column].Value = this.ActiveCell.Value; }
grid.UpdateData();
So here if I am updating 80k records then this for loop takes ~10sec and "grid.UpdateData()" method takes ~80sec.
Is it usual?
Or is there any better way to implement it?
Thanks,
Sunil
Hi Sunil,
The grid is a user interface control. It's designed for user interaction. So if you are performing a mass update on your data in code, it doesn't make a lot of sense to do it through the grid. You'd be better off modifying your data source directly instead of going through the UI.
Of course, if you do that, the grid will get notifications from the data source, so you probably want to turn those off so the grid doesn't respond to each one individually and slow things down.
grid.BeginUpdate(); grid.SuspendRowSynchronization(); try { // Loop through the data source and update the data here. } finally { grid.ResumeRowSynchronization(); grid.EndUpdate(); }
grid.BeginUpdate(); grid.SuspendRowSynchronization();
try { // Loop through the data source and update the data here. } finally { grid.ResumeRowSynchronization(); grid.EndUpdate(); }