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

GGC conditional format descriptor properties

Hi,
I'm using the following code to set properties conditionally at certian group levels:

// conditional formatting
// Declaring a conditional format descriptor.
GridConditionalFormatDescriptor gcfd = new GridConditionalFormatDescriptor();

// Setting some properties

gcfd.Appearance.AnyRecordFieldCell.Font.Bold = true;
gcfd.Appearance.AnyRecordFieldCell.Interior = new BrushInfo(Color.LightSeaGreen);

//Expression which is applied on the table data.
gcfd.Expression = @"[STATUS] like 'AVAILABLE' ";
Debug.WriteLine ("gcfd.expression?" + gcfd.Expression.ToString ());


// Setting name to the conditional format and adding it to the grid.
gcfd.Name = "gcfd";
grandChildTD.ConditionalFormats.Add(gcfd);
//


Question. How do I set properties for a particular cell on condition and not the whole row.

Thanks,

George.

2 Replies

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

Loader.
Live Chat Icon For mobile
Up arrow icon