AD
Administrator
Syncfusion Team
October 27, 2006 04:54 AM UTC
Hi George,
To format the cells based on the condition , you need to use the QueryCellStyleInfo event. Below is a code snipet.
private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
//To check the cell here
//For example all colIndex = 2 has been formatted properly
if(e.ColIndex == 2)
{
Element el = e.TableCellIdentity.DisplayElement;
if( el.Kind == DisplayElementKind.Record )
{
GridRecord rec = el.ParentRecord as GridRecord;
object obj = rec.GetValue("STATUS");
if(obj != null && obj.ToString() != string.Empty)
{
if( obj.ToString() == "AVAILABLE'")
{
e.Style.Font.Bold = true;
e.Style.Interior = new BrushInfo(Color.LightSeaGreen);
}
}
}
}
}
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
October 27, 2006 12:15 PM UTC
Perfect ! Thank you Haneef.
How to set the forecolor (text color) instead of the background ?
>Hi George,
To format the cells based on the condition , you need to use the QueryCellStyleInfo event. Below is a code snipet.
private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
//To check the cell here
//For example all colIndex = 2 has been formatted properly
if(e.ColIndex == 2)
{
Element el = e.TableCellIdentity.DisplayElement;
if( el.Kind == DisplayElementKind.Record )
{
GridRecord rec = el.ParentRecord as GridRecord;
object obj = rec.GetValue("STATUS");
if(obj != null && obj.ToString() != string.Empty)
{
if( obj.ToString() == "AVAILABLE'")
{
e.Style.Font.Bold = true;
e.Style.Interior = new BrushInfo(Color.LightSeaGreen);
}
}
}
}
}
Best Regards,
Haneef