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. Image for the cookie policy date

Number format: Red color for negative number

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!

1 Reply

AD Administrator Syncfusion Team August 17, 2004 08:29 PM UTC

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;
	}
}

Loader.
Live Chat Icon For mobile
Up arrow icon