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

Background Virtual Grid


I am trying to give the ability to change the background color of a cell on right click event. It seems to work fine if the cell is empty but once there is data in cell it does not change the background.

Sample Preview Mouse Down event

void SampleGridControl_MouseDown(object sender, MouseButtonEventArgs e)
{ RowColumnIndex _lastMouseDown = PointToCellRowColumnIndex(e);
if (e.RightButton == MouseButtonState.Pressed)
{
InvalidateCellBackground(_lastMouseDown);
Model[_lastMouseDown.RowIndex, _lastMouseDown.ColumnIndex].Background = Brushes.Crimson;
}
}

1 Reply

AD Administrator Syncfusion Team June 2, 2009 03:45 PM UTC

If you are using a true virtual grid, then normally, you would try to avoid code like:

grid.Model[row, col].Background = Brushes.Crimson;


The reason is that in a virtual grid, there is no storage automatically allocated to store cell specific properties.

In general, for a virtual grid, you would have to provide the Crimson brush in QueryCellInfo. In the mousedown event, you would just want to make sure QueryCellInfo is hit. Attached is a little sample that does this.




WpfApplication13_bbc314bb.zip

Loader.
Live Chat Icon For mobile
Up arrow icon