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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Cell background color in virtual mode

Thread ID:





95845 Aug 4,2010 04:07 AM UTC Aug 6,2010 01:21 PM UTC WPF 3
Tags: GridControl
Alex Gavrilov
Asked On August 4, 2010 04:07 AM UTC


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,


Jeraldes J [Syncfusion]
Replied On 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:


Let us know if you need any other details.

Jeraldes J

Alex Gavrilov
Replied On August 4, 2010 05:20 PM UTC


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.

Jeraldes J [Syncfusion]
Replied On 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.

Jeraldes J


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon