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.

Number format: Red color for negative number

Thread ID:

Created:

Updated:

Platform:

Replies:

17815 Aug 17,2004 03:12 PM Aug 17,2004 04:29 PM Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On August 17, 2004 03:12 PM

Hello, I''m wondering if there''s a way to emulate Excel''s number format for negative number, using the numberformat text. In Excel, it''s possible to put in color text (eg. [Red]) for the number format. The end user can change that through number format text. Is there a similar feature here? Thanks!

Administrator [Syncfusion]
Replied On August 17, 2004 04:29 PM

You will have to use an event like PrepareViewStyleInfo to dynamically change the text color.
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;
	}
}

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.

;