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. Image for the cookie policy date

Cell background color in virtual mode

Hi,

I am trying to get the grid to change the cell background color depending on some internal state information. I have the logic in the QueryCellInfo event which sets e.Style.Background to the brush I want but it appears to have no effect unless I call InvalidateVisuals(true) elsewhere in the code. If my understanding is correct InvalidateVisuals causes the entire grid to be repainted. In my case it's very undesirable as this a high-frequency update type of scenario. Please explain the right way to implement this. Thank you,

Alex

3 Replies

JJ Jeraldes J Syncfusion Team August 4, 2010 12:30 PM UTC

Hi Alex,

Thanks for using Syncfusion products.

When you call InvalidateVisual(true) it only clears the volatile styles, there may be some instances where the internal store would have cached the data.

You need to call Model.InvalidateCell(GridRangeInfo range); to mark the cell range as dirty, and then calling Model.InvalidateVisual(true) will force the grid to query for those particular cells again.

you can set the range the cell to be invalidated using the GridRangeInfo.

Sample code snippet:

gridControl.Model.InvalidateCell(GridRangeInfo.Table());
gridControl.InvalidateVisual(true);


Let us know if you need any other details.

Regards,
Jeraldes J


AG Alex Gavrilov August 4, 2010 05:20 PM UTC

Jeraldes,

I need some clearification here please. When I call InvalidateCell the document says it invalidates cached value for the cell and resets visuals associated with the cell.

1. What do you mean by visuals?
2. When you call the InvalidateVisual with "true" the doc says "forces complete new layout". The doc does not make the difference between InvalidateVisual() and InvalidateVisual(true) clear, please clearify.
3. If the InvalidateVisual(true) "forces complete new layout" it seems like a very inefficient way to go about this. Should we use InvalidateCellBackground?

Thank you.


JJ Jeraldes J Syncfusion Team August 6, 2010 01:21 PM UTC

Hi Alex,

1. Visual- we mean that the objects that are currently visible on the screen, including the cells, content of the cell and the styles of the cells that are visible on the screen.

2. InvalidateVisual() which will refresh the hole grid that are visible.

InvalidateVisual(true) – will update the cells that are dirt. Which means the cells that are to be updated alone will be updated. For example when you are using QueryCellInfo() to particular cells. Those updated cells are called as dirt cells, these dirt cells will only be invalidated using this InvalidateVisual(true).

3. If your requirement is only to change the background of the cells alone you can use the InvalidateCellBackground(). InvalidateVisual will invalidates the whole objects that are visual, as mentioned in 1.

Let us know if you face any other issues.

Regards,
Jeraldes J

Loader.
Live Chat Icon For mobile
Up arrow icon