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

Thread ID:

Created:

Updated:

Platform:

Replies:

5676 Jul 14,2003 04:29 AM UTC Jul 14,2003 06:14 AM UTC WinForms 1
loading
Tags: GridControl
Christian Morand
Asked On July 14, 2003 04:29 AM UTC

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

Administrator [Syncfusion]
Replied On 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
	}
}

CONFIRMATION

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.

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

;