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
close icon

How to access cell in GridDataControl


Hello,

In my project I have to change the cell background color depend on value in some DataTable which is not bind to the GridDataControl. My question is how to access the cell in GridDataControl and how to change the cell color.

Criterium for changing color is different for each cell and the solution is not condtional formating from your samples. The project is WPF.

Thanks in advance

Ivica


1 Reply

JJ Jeraldes J Syncfusion Team September 12, 2010 05:23 PM UTC

Hi Nikolic,

Thank you for using Syncfusion products.

QueryCellInfo is used to provide the cell values on demand. The QueryCellInfo is used to completely customize the grid cells. The code below sets up a Virtual Grid by applying these events and also paints alternate rows using QueryCellInfo event. The QueryCellInfo event is raised for each cell that requires redrawing.
Please refer the code snippet and the sample from the following

[Code Snippet]

this.dataGrid.Model.QueryCellInfo += new GridQueryCellInfoEventHandler(Model_QueryCellInfo);
void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if (e.Cell.ColumnIndex == 1 && e.Cell.RowIndex == 3)
{
e.Style.Background = Brushes.Brown;
}
}

Let us know if you need any other details.

Regards,
Jeraldes J




GDC-CellEdit-96394_e968942f.zip

Loader.
Live Chat Icon For mobile
Up arrow icon