Very high CPU usage when clearing cell data
Hello,
I have issues with a function that updates the ListGrid every 150ms from a IList<T>:
In the cells with data, I just update the value and the color (CurrentRow); for the remaining rows and cells I have this 2 nested fors to clear texx and color.
for (int r = CurrentRow; r < _ListGrid.RowCount; r++)
{
for (int c = 1; c <= _ListGrid.ColCount; c++)
{
_ListGrid.Model[r, c].CellValue = "";
_ListGrid.Model[r, c].BackColor = Color.Transparent;
_ListGrid.Model[r, c].TextColor = Color.Black;
}
}
This blocks the UI and uses a lot of CPU:
Is there a fastest way to clear cells? I've found this post with a similar problem but it's not my case.
Thank you for your help and time.
Daniele
SIGN IN To post a reply.
3 Replies
DA
Daniele
January 3, 2017 08:52 AM UTC
Sorry wrong image in the OP. That image is the report with the 2 for commented.

This is the correct image:
DA
Daniele
January 3, 2017 08:53 AM UTC
PM
Piruthiviraj Malaimelraj
Syncfusion Team
January 3, 2017 01:09 PM UTC
Hi Daniele,
Thanks for your interest in Syncfusion products.
We have created the simple sample as per your requirement . To clear the cell values instead of assigning null values through iteration, ClearCells method of grid can be used. In this method, particular range of cells can be cleared by using GridRangeInfo value. Please make use of the below code,
Code example:
int currentRow = this.gridControl1.CurrentCell.RowIndex;
int rowCount = this.gridControl1.Model.RowCount;
int colCount = this.gridControl1.Model.ColCount;
this.gridControl1.Model.ClearCells(GridRangeInfo.Cells(currentRow, 1, rowCount, colCount), true);
Please refer the below UG document for further references,
Sample link:
Note:
We would like to suggest to use VirtualGrid for your requirement. In VirtualGrid , all data will be supplied from external datasource at runtime. So you can use VirtualGrid to load the data on demand as per your scenario.
Please refer to the below documents for further references,
Regards,
Piruthiviraj
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
DA Daniele
- Jan 3, 2017 08:48 AM UTC
- Jan 3, 2017 01:09 PM UTC