[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Collapse]Editors and Simple Controls
    Included Controls and Components
   [Collapse]Common Editor Features and Concepts
    [Collapse]Input Mask
      Mask Type: Numeric
      Mask Type: Date-time
      Mask Type: TimeSpan
      Mask Type: Extended Regular Expressions
      Mask Type: Simple
      Mask Type: Simplified Regular Expressions
    [Expand]Format and Parse Editor Values
     Custom Editors
   [Expand]Lookup Editors
    Popup Container Editor
   [Expand]Token Edit Control
   [Expand]Breadcrumb Edit Control
   [Expand]Range Control
   [Expand]Image Slider
    Camera Control
    Templated ListBox Controls
   [Expand]Examples
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Mask Type: Numeric

Expanded Overview

The Numeric mask type allows users to enter numeric values (integer, float values, currencies, percentages, etc.). The numeric mask type supports the [standard numeric .Net format]"(https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings).

Note

Run the XtraEditors demo to try out input masks.

Mask Type and Mask Expression

The RepositoryItemTextEdit.Mask property provides access to a MaskProperties class instance that specifies an input mask. Set the MaskProperties.MaskType property to MaskType.Numeric to enable the numeric mask type. Use the MaskProperties.EditMask property to specify the mask expression.

Note

If an editor's value is an integer number, users are not allowed to enter the number's fraction part, even if the mask displays it.

Expanded Standard Masks

A standard numeric mask consists of a mask and precision specifier. The precision specifier ranges from 0 to 99 and sets the number of digits to the left or the right of a decimal point (depending on the mask specifier).

The table below contains input masks that correspond to the standard patterns. Note that patterns depend on the current culture. For example, the same input mask specifies different patterns in the USA and France (the currency symbol, the thousand separator, the precision, etc.). The System.Globalization.CultureInfo.NumberFormat property specifies a culture's numeric format. Users can change the regional format in the Windows Settings panel.

Specifier

Description

Remarks

Example (English (USA) culture)

C or c

Currency.

Users cannot edit the currency symbol.

The precision specifies the number of digits to the right of a decimal point. If the precision specifier is omitted, the mask uses the culture's System.Globalization.NumberFormatInfo.CurrencyDecimalDigits property.

  • Mask: c

    Value: 1024.5

  • Mask: c0

    Value: 20010

D or d

Integer decimal number.

If the editor's value is a non-integer number, the mask discards the fraction part.

The precision specifies the number of digits. If no precision is specified, the default is the minimum value required to represent the integer without leading zeros.

  • Mask: d

    Value: 1501

F or f

G or g

Non-integer decimal number.

The precision specifies the number of digits to the right of a decimal point. If the precision specifier is omitted, the mask uses the culture's System.Globalization.NumberFormatInfo.NumberDecimalDigits property.

  • Mask: f

    Value: 1024.5

N or n

Integer or non-integer decimal number.

The mask displays group (thousand) separators.

The precision specifies the number of digits to the right of a decimal point. If the precision specifier is omitted, the mask uses the culture's System.Globalization.NumberFormatInfo.NumberDecimalDigits property.

  • Mask: n

    Value: 1024.5

P

Percentage.

Displays the value as it is.

The masks matches the pattern specified by the culture's System.Globalization.NumberFormatInfo.PercentNegativePattern and System.Globalization.NumberFormatInfo.PercentPositivePattern properties.

The precision specifies the number of digits to the right of a decimal point. If the precision specifier is omitted, the mask uses the culture's System.Globalization.NumberFormatInfo.PercentDecimalDigits property.

  • Mask: P

    Value: 25

p

Percentage.

Multiplies the value by 100.

The masks matches the pattern specified by the culture's System.Globalization.NumberFormatInfo.PercentNegativePattern and System.Globalization.NumberFormatInfo.PercentPositivePattern properties.

The precision specifies the number of digits to the right of a decimal point. If the precision specifier is omitted, the mask uses the culture's System.Globalization.NumberFormatInfo.PercentDecimalDigits property.

  • Mask = p

    Value = 0.25

Expanded Custom Masks

Use the following placeholders and special characters to build custom numeric masks.

Placeholder

Name

Description

#

Digit.

Users can enter a decimal digit (0-9) at this position. If the user does not enter a digit, the editor does not fill this position with zero.

Note that if the mask is "#" and the value is "0", the editor displays an empty string.

0

Digit with default zero.

Users can enter a decimal digit (0-9) at this position. If the user does not enter a digit, the editor fills this position with zero.

.

Decimal point.

Specifies the decimal separator's location.

The culture's System.Globalization.NumberFormatInfo.NumberDecimalSeparator property specifies the actual decimal separator.

,

Group (thousand) separators.

Enables group (thousand) separators.

The culture's System.Globalization.NumberFormatInfo.NumberGroupSizes property specifies the number of digits in each group. The System.Globalization.NumberFormatInfo.NumberGroupSeparator property specifies the group separator character. If the mask contains the currency symbol ($), the System.Globalization.NumberFormatInfo.CurrencyGroupSizes and System.Globalization.NumberFormatInfo.CurrencyGroupSeparator properties are used. If the mask contains a percent symbol (%), the System.Globalization.NumberFormatInfo.PercentGroupSizes and System.Globalization.NumberFormatInfo.PercentGroupSeparator properties are used.

%

Percentage character.

Multiplies the value by 100.

The culture's System.Globalization.NumberFormatInfo.PercentSymbol property specifies the percent symbol.

%%

Percentage character.

Displays the value as it is.

The culture's System.Globalization.NumberFormatInfo.PercentSymbol property specifies the percent symbol.

\

Escape character.

Precede a placeholder or special character with a backslash to display the character in the edit box.

;

Mask separator.

Separates masks for positive and negative values.

The left-hand expression specifies the mask for positive values; right-hand - for negative values. If the right-hand expression is omitted, the editor does not allow users to enter negative values.

$

Currency character.

The culture's System.Globalization.NumberFormatInfo.CurrencySymbol property specifies the currency symbol.

Any other characters.

Any other characters are displayed in the edit box literally.

Examples

Example 1

#,##0.00 - a real number that has from 1 to 4 digits in the integer part and 2 digits in the fractional part. The integer part is divided into groups by three.

  • Value: 3080.6

  • Value: -3080.6

Example 2

#,##0.00;<<#,##0.00>> - a mask that encloses negative values with double angle brackets.

  • Value: -3080.6

Expanded End-User Capabilities

  • The Minus sign on the numeric keypad changes the number's sign. The caret can be placed at any position in the edit box.
  • The Up/Down Arrow keys, and the mouse wheel increment and decrement the digit to the left of the caret. If the entire number is selected, these keys increment and decrement the number's integer part.

Expanded See Also

Is this topic helpful?​​​​​​​