Numeric Controls

A numeric control is not a distinct control type, but is a special property that can be enabled for a text input control. It is used to display data in a specified format so that it is easier to read.

The numeric control property of a text control enables you to specify the display format of numeric and currency values. It only changes the way the control value is displayed and does not affect the way the value is edited or saved.

To define a format, you can use the following pattern:

PosPrefix PosFormat PosSuffix;NegPrefix NegFormat NegSuffix
Note: The spaces between prefix, format, and suffix are used only for clarity and should not be included in the actual format.

This pattern defines a format for positive numbers (PosPrefix PosFormat PosSuffix) and a format for negative numbers (NegPrefix NegFormat NegSuffix) separated by a semicolon (;).

The format can include the formatting characters shown in the table Numeric Control Formatting Characters. Each character is replaced with locale-specific text when the number is formatted.

Numeric Control Formatting Characters
Character Description
0 (Digit) Used to signify the minimum number of digits to be displayed. Each instance of the character represents a position for one digit. If no value exists in a position, a zero (0) is displayed. This character is not valid within prefix or suffix.

Left of the decimal point: leading 0's are shown.

Right of the decimal point: trailing 0's are shown.

# (Optional Digit) Used to signify the minimum number of digits to be displayed. Each instance of the character represents a position for one digit. If no value exists in a position, a blank space is displayed. This character is not valid within prefix or suffix.

Left of the decimal point: leading 0's are not shown.

Right of the decimal point: trailing 0's are not shown

. (Decimal separator) Used as a numeric or monetary decimal separator. This character is not valid within prefix or suffix and is localized based on the locale settings.
- (Minus sign) Used to indicate a negative number. This character is only valid in the prefix or suffix.
, (Grouping separator) Used to group the number format. The grouping separator must not be used to the right of the decimal point in a number format.

This character is localized and is not valid within prefix or suffix.

; Separates positive and negative sub-patterns. This character is not valid within number format, prefix or suffix.
¤ Currency sign (Unicode code point-\u00A4). This character is valid only within prefix or suffix and is replaced by the localized currency symbol.

Some sample formats are listed in the table Numeric Control Sample Formats:

Numeric Control Sample Formats
Number Format Pattern Displayed
0 0 0
0 #  
123 0 123
1234.123 #,###.0000 1,234.1230
1234.123 #,###.00 1,234.12
1234567.123 #,###.00 1,234,567.12
1234.123 000,000.00 001,234.12
1234.12345 #,##0.00## 1,234.1234
1234.123 #,##0.00## 1,234.123