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

Conditional Formatting


Hi

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)

1 Reply

AD Administrator Syncfusion Team December 22, 2006 11:06 AM UTC

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,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon