Files
Andy De George c0ba284473 Initial winforms content migrated (#18)
* Merge winforms framework content to working branch (#14)

* Breadcrumb / TOC / Move net5 to net folder (#15)

* change path from net5 to net

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Add .net 5 winforms placeholder article (#16)

* added some metadata and adjusted net5 placeholder

* corrections

* corrections

* corrections

* Test1

* Swapping landing page vs concept

* fix links

* Fix links

* Fix desc
2020-09-01 16:26:21 -07:00

2.8 KiB

title, ms.date, f1_keywords, helpviewer_keywords, ms.assetid
title ms.date f1_keywords helpviewer_keywords ms.assetid
How to: Set the Input Mask 03/30/2017
net.ComponentModel.MaskPropertyEditor
MaskedTextBox control [Windows Forms]
779b3a12-cd74-4e58-b46e-04983bda5b2c

How to: Set the Input Mask

The masked text box control is an enhanced text box control that supports a declarative syntax for accepting or rejecting user input. By setting the Mask property, you can specify the allowable user input without writing any custom validation logic in your application. For more information, see the Remarks section of the xref:System.Windows.Forms.MaskedTextBox class.

Setting the Mask Property Manually

If you are familiar with the characters that the Mask property supports, you can enter it manually. For a summary of the characters that the Mask property supports, see the Remarks section of the xref:System.Windows.Forms.MaskedTextBox.Mask%2A property.

To set the Mask property manually

  1. In Design view, select a xref:System.Windows.Forms.MaskedTextBox.

  2. In the Properties window, locate the xref:System.Windows.Forms.MaskedTextBox.Mask%2A property.

  3. Type the mask that you want. For example, type ###.

Using the Input Mask Dialog Box

The Input Mask dialog box provides some predefined input masks. You can also change the predefined masks or enter your own mask manually.

To open the Input Mask dialog box

  1. In Design view, select a xref:System.Windows.Forms.MaskedTextBox.

    1. Click the smart tag to open the MaskedTextBox Tasks panel.

    2. Click Set Mask.

    - or -

    1. In the Properties window, select the xref:System.Windows.Forms.MaskedTextBox.Mask%2A property.

    2. Click the ellipsis button in the property value column.

    The Input Mask dialog box appears.

To use the Input Mask dialog box

  1. (Optional) Click one of the predefined masks in the list.

  2. (Optional) Edit the predefined mask in the Mask box.

  3. (Optional) Type a new mask in the Mask box. That is, you do not have to use one of the predefined masks.

    Note

    The Preview box displays the characters that the user sees in the xref:System.Windows.Forms.MaskedTextBox. These characters are a guide to help the user enter the data correctly.

  4. Select or clear the Use ValidatingType check box. The Use ValidatingType check box specifies whether a data type is used to verify the data input by the user. For more information, see the xref:System.Windows.Forms.MaskedTextBox.ValidatingType%2A property.

  5. Click OK.

    The mask is entered in the Mask property in the Properties window.

See also