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 databound grid

Hello. Is there an easy way to directly set the background color of a cell in databound grid? For example, when the cell contains some specific value I would like to have its background painted with a specific color. Regards Christian

1 Reply

AD Administrator Syncfusion Team July 14, 2003 06:14 AM UTC

You can use PrepareViewStyleInfo...
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	if(e.ColIndex > 0 && e.RowIndex > 0)
	{
		try
		{
			double dValue = double.Parse(e.Style.Text);
			if( dValue > 100 )
			{
        			e.Style.BackColor = Color.Red;
			}
		}
		catch { } //empty
	}
}

Loader.
Live Chat Icon For mobile
Up arrow icon