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.
Unfortunately, activation email could not send to your email. Please try again.

Conditional Formatting

Thread ID:





53908 Dec 22,2006 05:49 AM Dec 22,2006 06:06 AM Windows Forms 1
Tags: GridControl
Asked On December 22, 2006 05:49 AM


Is there any conditional formatting available in DataBoundGrid like if value of a particular cell is greater than 25 then the background color would be blue (any color i can define on run-time)

Administrator [Syncfusion]
Replied On December 22, 2006 06:06 AM

Hi Ubaid,

To set cell specific properties in a GridDataBoundGrid, you must catch the PrepareViewStyleInfo event (or Model.QueryCellInfo event). In your handler, you check e.RowIndex and e.ColIndex, and if these point to the cell you want to change, you set e.Style.BackColor to the value you want. Below is a code snippet to change backcolor to Color.Red when the Text having the number greater than 25.

private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
if( e.Style.Text != null && e.Style.Text != string.Empty
&& e.Style.CellValueType == typeof(int))
int number = int.Parse(e.Style.Text);
if( number > 25)
e.Style.BackColor = Color.AliceBlue ;

Best Regards,


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.

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.