Hi David,
Thanks for posting your query to us.
I regret to let you know that the formatting of specific cells based on conditions can be achieved only through QueryCellStyleInfo event. But you can apply format based on conditions for the entire row. Please refer the following code snippet:
protected void Page_Load(object sender, EventArgs e)
{
GridConditionalFormatDescriptor gcfd1 = new GridConditionalFormatDescriptor();
gcfd1.Expression= "[CategoryID]<2";
gcfd1.Appearance.AnyRecordFieldCell.BackColor = System.Drawing.Color.Red;
this.GridGroupingControl1.TableDescriptor.ConditionalFormats.Add(gcfd1);
}
To apply format for specific column:
protected void GridGroupingControl1_QueryCellStyleInfo1(object sender, GridTableCellStyleInfoEventArgs e)
{
if ((e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell))
{
if (e.TableCellIdentity.Column.Name == "CategoryID")
{
val1 = (System.Int32)e.Style.CellValue;
}
if (e.TableCellIdentity.Column.Name == "SupplierID")
{
val2 = (System.Int32)e.Style.CellValue;
}
if ((val2 < val1)&&(e.TableCellIdentity.Column.Name == "CategoryID"))
e.Style.TextColor = System.Drawing.Color.Magenta;
}
}
Please refer the sample in the link below which illustrates the above:
http://websamples.syncfusion.com/samples/Grid.Web/6.2.0.40/Grid_ASP_format/main.htm
Please try running the sample and let me know if this helps.
Thanks,
Janagan.