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.
Syncfusion Feedback

GridConditionalFormatDescriptor - how to format single cell?

Thread ID:





76155 Aug 25,2008 11:18 PM Aug 29,2008 08:21 AM Windows Forms 1
Tags: Grouping
Julien Chevalley
Asked On August 25, 2008 11:18 PM


Is there any way GridConditionalFormatDescriptor can be used to format a single cell instead of the whole row?



SubhaSheela R [Syncfusion]
Replied On August 29, 2008 08:21 AM

Hi Julien,

Thanks for using Syncfusion Products.

GridConditionalFormatDescriptor only allow you to row formatting. If you want to format any one cell, then you need to use QueryCellStyleInfo or PrepareViewStyleInfo event to achieve that. Below is the example that shows to change backcolor of a negative value cell and bracket for nagative value cell. Please refer to the below code in which QueryCellStyleInfo event is used to achieve your need.

this.gridGroupingControl1.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo);
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell
|| e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
if (e.TableCellIdentity.Column.MappingName == "B")
int cellvalue = Convert.ToInt32(e.Style.CellValue);
if (cellvalue < 0)
e.Style.BackColor = Color.Red;
e.Style.Format = "{#,##}"; // You can set your own format

Please refer to the sample given below which illustrates the above:


Please let me know if you have any question.

Subhasheela R


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.

Warning Icon 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.Close Icon