Gets or sets the input mask to use at run time.
A String representing the current mask. The default value is the empty string which allows any input.
Mask must be a string composed of one or more of the masking elements, as shown in the following table. The masking language used by MaskedTextBox is defined by its associated MaskedTextProvider.
| Masking element | Description |
|---|---|
| 0 | Digit, required. This element will accept any single digit between 0 and 9. |
| 9 | Digit or space, optional. |
| L | Lower case letter, required. Restricts input to the ASCII letters a-z. This mask element is equivalent to [a-z] in regular expressions. |
| l | Lower case letter, optional. Restricts input to the ASCII letters a-z. This mask element is equivalent to [a-z ] in regular expressions. |
| U | Upper case letter, required. Restricts input to the ASCII letters A-Z. This mask element is equivalent to [A-Z] in regular expressions. |
| u | Upper case letter, optional. Restricts input to the ASCII letters A-Z. This mask element is equivalent to [A-Z ] in regular expressions. |
| A | Letter, required. Restricts input to the ASCII letters a-z and A-Z. This mask element is equivalent to [a-zA-Z] in regular expressions. |
| a | Letter, optional. Restricts input to the ASCII letters a-z and A-Z. This mask element is equivalent to [a-zA-Z ] in regular expressions. |
| D | Alphanumeric, required. Restricts input to the single digit 0-9 and ASCII letters a-z, and A-Z. This mask element is equivalent to [a-zA-Z0-9] in regular expressions. |
| d | Alphanumeric, optional. Restricts input to the single digit 0-9 and ASCII letters a-z, and A-Z. This mask element is equivalent to [a-zA-Z0-9 ] in regular expressions. |
| C | Character, required. Any character. |
| \ | Escape. Escapes a mask character, turning it into a literal. "\0" is the escape sequence for literal 0. |
| All other characters | Literals. All non-mask elements will appear as themselves within MaskedTextBox. Literals always occupy a static position in the mask at run time, and cannot be moved or deleted by the user. |
If you change a mask when MaskedTextBox already contains user input filtered by a previous mask, MaskedTextBox will attempt to migrate that input into the new mask definition. If it fails, it will clear the existing input. Assigning a zero-length string as the mask will preserve any existing data in the control. When used with a zero-length mask, MaskedTextBox behaves like a single-line TextBox control.
Users can navigate through the mask by using the left and right arrow keys or the mouse cursor, and can skip optional positions in the mask by entering a space.
MaskedTextBox Class | Resco.Controls.MaskedTextBox Namespace