MaskedTextProvider Class
TOC
Collapse the table of content
Expand the table of content

MaskedTextProvider Class

 

Represents a mask-parsing service that can be used by any number of controls that support masking, such as the MaskedTextBox control.

Namespace:   System.ComponentModel
Assembly:  System (in System.dll)

System.Object
  System.ComponentModel.MaskedTextProvider

[HostProtectionAttribute(SecurityAction.LinkDemand, SharedState = true)]
public class MaskedTextProvider : ICloneable

NameDescription
System_CAPS_pubmethodMaskedTextProvider(String)

Initializes a new instance of the MaskedTextProvider class using the specified mask.

System_CAPS_pubmethodMaskedTextProvider(String, Boolean)

Initializes a new instance of the MaskedTextProvider class using the specified mask and ASCII restriction value.

System_CAPS_pubmethodMaskedTextProvider(String, Char, Boolean)

Initializes a new instance of the MaskedTextProvider class using the specified mask, password character, and prompt usage value.

System_CAPS_pubmethodMaskedTextProvider(String, CultureInfo)

Initializes a new instance of the MaskedTextProvider class using the specified mask and culture.

System_CAPS_pubmethodMaskedTextProvider(String, CultureInfo, Boolean)

Initializes a new instance of the MaskedTextProvider class using the specified mask, culture, and ASCII restriction value.

System_CAPS_pubmethodMaskedTextProvider(String, CultureInfo, Boolean, Char, Char, Boolean)

Initializes a new instance of the MaskedTextProvider class using the specified mask, culture, prompt usage value, prompt character, password character, and ASCII restriction value.

System_CAPS_pubmethodMaskedTextProvider(String, CultureInfo, Char, Boolean)

Initializes a new instance of the MaskedTextProvider class using the specified mask, culture, password character, and prompt usage value.

NameDescription
System_CAPS_pubpropertyAllowPromptAsInput

Gets a value indicating whether the prompt character should be treated as a valid input character or not.

System_CAPS_pubpropertyAsciiOnly

Gets a value indicating whether the mask accepts characters outside of the ASCII character set.

System_CAPS_pubpropertyAssignedEditPositionCount

Gets the number of editable character positions that have already been successfully assigned an input value.

System_CAPS_pubpropertyAvailableEditPositionCount

Gets the number of editable character positions in the input mask that have not yet been assigned an input value.

System_CAPS_pubpropertyCulture

Gets the culture that determines the value of the localizable separators and placeholders in the input mask.

System_CAPS_pubpropertySystem_CAPS_staticDefaultPasswordChar

Gets the default password character used obscure user input.

System_CAPS_pubpropertyEditPositionCount

Gets the number of editable positions in the formatted string.

System_CAPS_pubpropertyEditPositions

Gets a newly created enumerator for the editable positions in the formatted string.

System_CAPS_pubpropertyIncludeLiterals

Gets or sets a value that indicates whether literal characters in the input mask should be included in the formatted string.

System_CAPS_pubpropertyIncludePrompt

Gets or sets a value indicating whether PromptChar is used to represent the absence of user input when displaying the formatted string.

System_CAPS_pubpropertySystem_CAPS_staticInvalidIndex

Gets the upper bound of the range of invalid indexes.

System_CAPS_pubpropertyIsPassword

Gets or sets a value that determines whether password protection should be applied to the formatted string.

System_CAPS_pubpropertyItem[Int32]

Gets the element at the specified position in the formatted string.

System_CAPS_pubpropertyLastAssignedPosition

Gets the index in the mask of the rightmost input character that has been assigned to the mask.

System_CAPS_pubpropertyLength

Gets the length of the mask, absent any mask modifier characters.

System_CAPS_pubpropertyMask

Gets the input mask.

System_CAPS_pubpropertyMaskCompleted

Gets a value indicating whether all required inputs have been entered into the formatted string.

System_CAPS_pubpropertyMaskFull

Gets a value indicating whether all required and optional inputs have been entered into the formatted string.

System_CAPS_pubpropertyPasswordChar

Gets or sets the character to be substituted for the actual input characters.

System_CAPS_pubpropertyPromptChar

Gets or sets the character used to represent the absence of user input for all available edit positions.

System_CAPS_pubpropertyResetOnPrompt

Gets or sets a value that determines how an input character that matches the prompt character should be handled.

System_CAPS_pubpropertyResetOnSpace

Gets or sets a value that determines how a space input character should be handled.

System_CAPS_pubpropertySkipLiterals

Gets or sets a value indicating whether literal character positions in the mask can be overwritten by their same values.

NameDescription
System_CAPS_pubmethodAdd(Char)

Adds the specified input character to the end of the formatted string.

System_CAPS_pubmethodAdd(Char, Int32, MaskedTextResultHint)

Adds the specified input character to the end of the formatted string, and then outputs position and descriptive information.

System_CAPS_pubmethodAdd(String)

Adds the characters in the specified input string to the end of the formatted string.

System_CAPS_pubmethodAdd(String, Int32, MaskedTextResultHint)

Adds the characters in the specified input string to the end of the formatted string, and then outputs position and descriptive information.

System_CAPS_pubmethodClear()

Clears all the editable input characters from the formatted string, replacing them with prompt characters.

System_CAPS_pubmethodClear(MaskedTextResultHint)

Clears all the editable input characters from the formatted string, replacing them with prompt characters, and then outputs descriptive information.

System_CAPS_pubmethodClone()

Creates a copy of the current MaskedTextProvider.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodFindAssignedEditPositionFrom(Int32, Boolean)

Returns the position of the first assigned editable position after the specified position using the specified search direction.

System_CAPS_pubmethodFindAssignedEditPositionInRange(Int32, Int32, Boolean)

Returns the position of the first assigned editable position between the specified positions using the specified search direction.

System_CAPS_pubmethodFindEditPositionFrom(Int32, Boolean)

Returns the position of the first editable position after the specified position using the specified search direction.

System_CAPS_pubmethodFindEditPositionInRange(Int32, Int32, Boolean)

Returns the position of the first editable position between the specified positions using the specified search direction.

System_CAPS_pubmethodFindNonEditPositionFrom(Int32, Boolean)

Returns the position of the first non-editable position after the specified position using the specified search direction.

System_CAPS_pubmethodFindNonEditPositionInRange(Int32, Int32, Boolean)

Returns the position of the first non-editable position between the specified positions using the specified search direction.

System_CAPS_pubmethodFindUnassignedEditPositionFrom(Int32, Boolean)

Returns the position of the first unassigned editable position after the specified position using the specified search direction.

System_CAPS_pubmethodFindUnassignedEditPositionInRange(Int32, Int32, Boolean)

Returns the position of the first unassigned editable position between the specified positions using the specified search direction.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticGetOperationResultFromHint(MaskedTextResultHint)

Determines whether the specified MaskedTextResultHint denotes success or failure.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodInsertAt(Char, Int32)

Inserts the specified character at the specified position within the formatted string.

System_CAPS_pubmethodInsertAt(Char, Int32, Int32, MaskedTextResultHint)

Inserts the specified character at the specified position within the formatted string, returning the last insertion position and the status of the operation.

System_CAPS_pubmethodInsertAt(String, Int32)

Inserts the specified string at a specified position within the formatted string.

System_CAPS_pubmethodInsertAt(String, Int32, Int32, MaskedTextResultHint)

Inserts the specified string at a specified position within the formatted string, returning the last insertion position and the status of the operation.

System_CAPS_pubmethodIsAvailablePosition(Int32)

Determines whether the specified position is available for assignment.

System_CAPS_pubmethodIsEditPosition(Int32)

Determines whether the specified position is editable.

System_CAPS_pubmethodSystem_CAPS_staticIsValidInputChar(Char)

Determines whether the specified character is a valid input character.

System_CAPS_pubmethodSystem_CAPS_staticIsValidMaskChar(Char)

Determines whether the specified character is a valid mask character.

System_CAPS_pubmethodSystem_CAPS_staticIsValidPasswordChar(Char)

Determines whether the specified character is a valid password character.

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodRemove()

Removes the last assigned character from the formatted string.

System_CAPS_pubmethodRemove(Int32, MaskedTextResultHint)

Removes the last assigned character from the formatted string, and then outputs the removal position and descriptive information.

System_CAPS_pubmethodRemoveAt(Int32)

Removes the assigned character at the specified position from the formatted string.

System_CAPS_pubmethodRemoveAt(Int32, Int32)

Removes the assigned characters between the specified positions from the formatted string.

System_CAPS_pubmethodRemoveAt(Int32, Int32, Int32, MaskedTextResultHint)

Removes the assigned characters between the specified positions from the formatted string, and then outputs the removal position and descriptive information.

System_CAPS_pubmethodReplace(Char, Int32)

Replaces a single character at or beyond the specified position with the specified character value.

System_CAPS_pubmethodReplace(Char, Int32, Int32, Int32, MaskedTextResultHint)

Replaces a single character between the specified starting and ending positions with the specified character value, and then outputs the removal position and descriptive information.

System_CAPS_pubmethodReplace(Char, Int32, Int32, MaskedTextResultHint)

Replaces a single character at or beyond the specified position with the specified character value, and then outputs the removal position and descriptive information.

System_CAPS_pubmethodReplace(String, Int32)

Replaces a range of editable characters starting at the specified position with the specified string.

System_CAPS_pubmethodReplace(String, Int32, Int32, Int32, MaskedTextResultHint)

Replaces a range of editable characters between the specified starting and ending positions with the specified string, and then outputs the removal position and descriptive information.

System_CAPS_pubmethodReplace(String, Int32, Int32, MaskedTextResultHint)

Replaces a range of editable characters starting at the specified position with the specified string, and then outputs the removal position and descriptive information.

System_CAPS_pubmethodSet(String)

Sets the formatted string to the specified input string.

System_CAPS_pubmethodSet(String, Int32, MaskedTextResultHint)

Sets the formatted string to the specified input string, and then outputs the removal position and descriptive information.

System_CAPS_pubmethodToDisplayString()

Returns the formatted string in a displayable form.

System_CAPS_pubmethodToString()

Returns the formatted string that includes all the assigned character values.(Overrides Object.ToString().)

System_CAPS_pubmethodToString(Boolean)

Returns the formatted string, optionally including password characters.

System_CAPS_pubmethodToString(Boolean, Boolean)

Returns the formatted string, optionally including prompt and literal characters.

System_CAPS_pubmethodToString(Boolean, Boolean, Boolean, Int32, Int32)

Returns a substring of the formatted string, optionally including prompt, literal, and password characters.

System_CAPS_pubmethodToString(Boolean, Boolean, Int32, Int32)

Returns a substring of the formatted string, optionally including prompt and literal characters.

System_CAPS_pubmethodToString(Boolean, Int32, Int32)

Returns a substring of the formatted string, optionally including password characters.

System_CAPS_pubmethodToString(Int32, Int32)

Returns a substring of the formatted string.

System_CAPS_pubmethodVerifyChar(Char, Int32, MaskedTextResultHint)

Tests whether the specified character could be set successfully at the specified position.

System_CAPS_pubmethodVerifyEscapeChar(Char, Int32)

Tests whether the specified character would be escaped at the specified position.

System_CAPS_pubmethodVerifyString(String)

Tests whether the specified string could be set successfully.

System_CAPS_pubmethodVerifyString(String, Int32, MaskedTextResultHint)

Tests whether the specified string could be set successfully, and then outputs position and descriptive information.

The MaskedTextBox control contains a mask, composed of literal characters and formatting elements, that it tests all user input against. Instead of permanently associating a specific mask-parsing engine with MaskedTextBox, Windows Forms provides it as a separate service, represented by the MaskedTextProvider class, which defines the syntax of the masking language discussed in the documentation for the Mask property.

Many of the members of the MaskedTextBox class refer their implementation to similarly named members of the associated MaskedTextProvider. For example, the MaskedTextBox.PromptChar property of the MaskedTextBox class refers all access to the PromptChar of the MaskedTextProvider class.

The mask-parsing engine used by MaskedTextProvider is modeled after the Masked Edit control included in Microsoft Visual Basic version 6. Its masking language is described in the documentation for the Mask property.

The following three distinct strings are involved with the MaskedTextProvider class.

String name

Description

Input character or string

Represents the characters used as input that the mask is applied against. In actuality, the input string may be composed of multiple input operations, including Add, Replace, InsertAt, and Remove. Therefore, the input string cannot be accessed directly. However, aspects of the input string handling are available though the AllowPromptAsInput and AsciiOnly, ResetOnPrompt, and ResetOnSpace properties.

Mask

Represents the input formatting mask used to transform the input string into the formatted string. This string is set in the MaskedTextProvider and accessed primarily though the Mask property. Characteristics of the mask are also available through other members, such as the Length, PasswordChar, and PromptChar properties.

Formatted string

Represents the string that results when the full mask is applied to the input string. The formatted string can be queried with many members of the class, including Item, Length, LastAssignedPosition, MaskFull, MaskCompleted, FindEditPositionFrom, and so on. The full value of the formatted string is available from the ToDisplayString and ToString methods.

System_CAPS_noteNote

The input string may represent direct user input, as in the case of the MaskedTextBox, or may be generated by other processes not directly associated with user input/output operations.

.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft