Masked Text Box Mask - Matéria Programação 2 PDF

Title Masked Text Box Mask - Matéria Programação 2
Course Programação
Institution Universidade de Coimbra
Pages 4
File Size 126.6 KB
File Type PDF
Total Downloads 10
Total Views 173

Summary

Matéria Programação 2...


Description

20/03/2018

MaskedTextBox.Mask Property (System.Windows.Forms) | Microsoft Docs

MaskedTextBox.Mask Property Namespace: System.Windows.Forms Assembly: System.Windows.Forms.dll

In This Article Definition Remarks Applies to See Also

Gets or sets the input mask to use at run time. C#

Copy

public string Mask { get; set; }

Property Value String A String representing the current mask. The default value is the empty string which allows any input. Exceptions ArgumentException The string supplied to the Mask property is not a valid mask. Invalid masks include masks containing non-printable characters.

Remarks Mask is the default property for the MaskedTextBox class. 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. The standard provider specifies a masking language based upon the one used by the Masked Edit control in Visual Basic 6.0, and should be very familiar to users migrating from that platform. Masking element

Description

0

Digit, required. This element will accept any single digit between 0 and 9.

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.maskedtextbox.mask?view=netframework-4.7.1

1/4

20/03/2018

MaskedTextBox.Mask Property (System.Windows.Forms) | Microsoft Docs

Masking element

Description

9

Digit or space, optional.

#

Digit or space, optional. If this position is blank in the mask, it will be rendered as a space in the Text property. Plus (+) and minus (-) signs are allowed.

L

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.

?

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.

&

Character, required. If the AsciiOnly property is set to true, this element behaves like the "L" element.

C

Character, optional. Any non-control character. If the AsciiOnly property is set to true , this element behaves like the "?" element.

A

Alphanumeric, required. If the AsciiOnly property is set to true , the only characters it will accept are the ASCII letters a-z and A-Z. This mask element behaves like the "a" element.

a

Alphanumeric, optional. If the AsciiOnly property is set to true , the only characters it will accept are the ASCII letters a-z and A-Z. This mask element behaves like the "A" element.

.

Decimal placeholder. The actual display character used will be the decimal symbol appropriate to the format provider, as determined by the control's FormatProvider property.

,

Thousands placeholder. The actual display character used will be the thousands placeholder appropriate to the format provider, as determined by the control's FormatProvider property.

:

Time separator. The actual display character used will be the time symbol appropriate to the format provider, as determined by the control's FormatProvider property.

/

Date separator. The actual display character used will be the date symbol appropriate to the format provider, as determined by the control's FormatProvider property.

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.maskedtextbox.mask?view=netframework-4.7.1

2/4

20/03/2018

MaskedTextBox.Mask Property (System.Windows.Forms) | Microsoft Docs

Masking element

Description

$

Currency symbol. The actual character displayed will be the currency symbol appropriate to the format provider, as determined by the control's FormatProvider property.

<

Shift down. Converts all characters that follow to lowercase.

>

Shift up. Converts all characters that follow to uppercase.

|

Disable a previous shift up or shift down.

|Escape. Escapes a mask character, turning it into a literal. "\\" is the escape sequence for a backslash. 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 singleline TextBox control. The decimal (.), thousandths (,), time (:), date (/), and currency ($) symbols default to displaying those symbols as defined by the application's culture. You can force them to display symbols for another culture by using the FormatProvider property. Character insertion into the mask at run time is controlled by the InsertKeyMode property. 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.

 Important MaskedTextBox supports all Unicode characters except for surrogates and vertically combined characters.

The following table shows example masks. Mask

Behavior

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.maskedtextbox.mask?view=netframework-4.7.1

3/4

20/03/2018

MaskedTextBox.Mask Property (System.Windows.Forms) | Microsoft Docs

Mask 00/00/0000

Behavior A date (day, numeric month, year) in international date format. The "/" character is a logical date separator, and will appear to the user as the date separator appropriate to the application's current culture.

00->L...


Similar Free PDFs