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.

Red text for negative values in cells

Thread ID:

Created:

Updated:

Platform:

Replies:

48114 Aug 20,2006 08:03 PM Nov 2,2010 06:45 AM Windows Forms 4
loading
Tags: GridControl
Terence Rossow
Asked On August 20, 2006 08:03 PM

G''day,

I need to be able to set a format for numbers (for a cell in a grid) so that when the cell contains a negative value, the number will show up red. Is this possible?

Cheers,
TERRY

Administrator [Syncfusion]
Replied On August 21, 2006 01:01 AM

Hi Terry,

If you use a CurrencyEdit celltype, you can use style.CurrencyEdit.NegativeColor to set this color. But if you are using other celltypes, then you would have to handle PrepareViewStyleInfo event to dynamically change the textcolor. Here is some code snippet.

private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
double d;
if(e.RowIndex > 0 && e.ColIndex == 2
&& double.TryParse(e.Style.Text, System.Globalization.NumberStyles.Any, null, out d)
&& d < 0)
{
e.Style.TextColor = Color.Red;
}
}

Thanks for using Syncfusion Products.
Regards,
Rajagopal

Robert Avery
Replied On October 18, 2010 06:02 PM

Is this still the only way to color the text red if the number is negative? Thanks.


Nirmal Raja [Syncfusion]
Replied On November 2, 2010 06:44 AM

Hi Robert,

This is the best way to provide color to the cell conditionally, which gets updated dynamically on any changes in the grid description. The GridGroupingControl can have the Conditional Format, which helps the row to be in certain color which is related to the condition.

Please let me know if you find any issue with this way of achieving the behavior, so that we can look into the specific perpective and provide you a fixed sample.

Let me know if you have any concern.

Regards,
Nirmal


Nirmal Raja [Syncfusion]
Replied On November 2, 2010 06:45 AM

Hi Robert,

This is the best way to provide color to the cell conditionally, which gets updated dynamically on any changes in the grid description. The GridGroupingControl can have the Conditional Format, which helps the row to be in certain color which is related to the condition.

Please let me know if you find any issue with this way of achieving the behavior, so that we can look into the specific perpective and provide you a fixed sample.

Let me know if you have any concern.

Regards,
Nirmal


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.

;