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.

GGC conditional format descriptor properties

Thread ID:

Created:

Updated:

Platform:

Replies:

51031 Oct 26,2006 08:27 AM Oct 27,2006 08:15 AM Windows Forms 2
loading
Tags: GridControl
George Thomas
Asked On October 26, 2006 08:27 AM

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.

Administrator [Syncfusion]
Replied On October 27, 2006 12:54 AM

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

Administrator [Syncfusion]
Replied On October 27, 2006 08:15 AM

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

CONFIRMATION

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.

;