We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Very high CPU usage when clearing cell data

Thread ID:

Created:

Updated:

Platform:

Replies:

128110 Jan 3,2017 03:48 AM Jan 3,2017 08:09 AM Windows Forms 3
loading
Tags: GridListControl
Daniele
Asked On January 3, 2017 03:48 AM

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



Daniele
Replied On January 3, 2017 03:52 AM

Sorry wrong image in the OP. That image is the report with the 2 for commented.
This is the correct image:





Daniele
Replied On January 3, 2017 03:53 AM

http://imgur.com/eTrFQo9

Sorry... There is no preview and no edit :D

Piruthiviraj Malaimelraj [Syncfusion]
Replied On January 3, 2017 08:09 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;