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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridConditionalFormatDescriptor - how to format single cell?

Thread ID:

Created:

Updated:

Platform:

Replies:

76155 Aug 26,2008 03:18 AM UTC Aug 29,2008 12:21 PM UTC WinForms 1
loading
Tags: Grouping
Julien Chevalley
Asked On August 26, 2008 03:18 AM UTC

Hi,

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

Thanks,

Julien


SubhaSheela R [Syncfusion]
Replied On August 29, 2008 12:21 PM UTC

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:

http://websamples.syncfusion.com/samples/Grid.Windows/I41286/main.htm

Please let me know if you have any question.

Regards,
Subhasheela R





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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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

;