Back to Devexpress

How to: Format a Numeric Value according to its Sign

windowsforms-2148-common-features-formatting-values-how-to-format-a-numeric-value-according-to-its-sign.md

latest870 B
Original Source

How to: Format a Numeric Value according to its Sign

  • Nov 13, 2018

The following example shows how to provide different formats for positive and negative numeric values and the zero value in a CalcEdit editor.

The result is demonstrated in the image below.

csharp
using DevExpress.Utils;
// ...
calcEdit1.Properties.DisplayFormat.FormatType = FormatType.Numeric;
calcEdit1.Properties.DisplayFormat.FormatString = "#.00;[#.0];Zero";
vb
Imports DevExpress.Utils
' ...
CalcEdit1.Properties.DisplayFormat.FormatType = FormatType.Numeric
CalcEdit1.Properties.DisplayFormat.FormatString = "#.00;[#.0];Zero"