Edit

Share via


MaskedTextProvider Class

Definition

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

public ref class MaskedTextProvider : ICloneable
public class MaskedTextProvider : ICloneable
type MaskedTextProvider = class
    interface ICloneable
Public Class MaskedTextProvider
Implements ICloneable
Inheritance
MaskedTextProvider
Implements

Remarks

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.

Note

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.

Constructors

MaskedTextProvider(String, Boolean)

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

MaskedTextProvider(String, Char, Boolean)

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

MaskedTextProvider(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.

MaskedTextProvider(String, CultureInfo, Boolean)

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

MaskedTextProvider(String, CultureInfo, Char, Boolean)

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

MaskedTextProvider(String, CultureInfo)

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

MaskedTextProvider(String)

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

Properties

AllowPromptAsInput

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

AsciiOnly

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

AssignedEditPositionCount

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

AvailableEditPositionCount

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

Culture

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

DefaultPasswordChar

Gets the default password character used obscure user input.

EditPositionCount

Gets the number of editable positions in the formatted string.

EditPositions

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

IncludeLiterals

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

IncludePrompt

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

InvalidIndex

Gets the upper bound of the range of invalid indexes.

IsPassword

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

Item[Int32]

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

LastAssignedPosition

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

Length

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

Mask

Gets the input mask.

MaskCompleted

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

MaskFull

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

PasswordChar

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

PromptChar

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

ResetOnPrompt

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

ResetOnSpace

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

SkipLiterals

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

Methods

Add(Char, Int32, MaskedTextResultHint)

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

Add(Char)

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

Add(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.

Add(String)

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

Clear()

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

Clear(MaskedTextResultHint)

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

Clone()

Creates a copy of the current MaskedTextProvider.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
FindAssignedEditPositionFrom(Int32, Boolean)

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

FindAssignedEditPositionInRange(Int32, Int32, Boolean)

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

FindEditPositionFrom(Int32, Boolean)

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

FindEditPositionInRange(Int32, Int32, Boolean)

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

FindNonEditPositionFrom(Int32, Boolean)

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

FindNonEditPositionInRange(Int32, Int32, Boolean)

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

FindUnassignedEditPositionFrom(Int32, Boolean)

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

FindUnassignedEditPositionInRange(Int32, Int32, Boolean)

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

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetOperationResultFromHint(MaskedTextResultHint)

Determines whether the specified MaskedTextResultHint denotes success or failure.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
InsertAt(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.

InsertAt(Char, Int32)

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

InsertAt(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.

InsertAt(String, Int32)

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

IsAvailablePosition(Int32)

Determines whether the specified position is available for assignment.

IsEditPosition(Int32)

Determines whether the specified position is editable.

IsValidInputChar(Char)

Determines whether the specified character is a valid input character.

IsValidMaskChar(Char)

Determines whether the specified character is a valid mask character.

IsValidPasswordChar(Char)

Determines whether the specified character is a valid password character.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Remove()

Removes the last assigned character from the formatted string.

Remove(Int32, MaskedTextResultHint)

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

RemoveAt(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.

RemoveAt(Int32, Int32)

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

RemoveAt(Int32)

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

Replace(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.

Replace(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.

Replace(Char, Int32)

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

Replace(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.

Replace(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.

Replace(String, Int32)

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

Set(String, Int32, MaskedTextResultHint)

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

Set(String)

Sets the formatted string to the specified input string.

ToDisplayString()

Returns the formatted string in a displayable form.

ToString()

Returns the formatted string that includes all the assigned character values.

ToString(Boolean, Boolean, Boolean, Int32, Int32)

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

ToString(Boolean, Boolean, Int32, Int32)

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

ToString(Boolean, Boolean)

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

ToString(Boolean, Int32, Int32)

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

ToString(Boolean)

Returns the formatted string, optionally including password characters.

ToString(Int32, Int32)

Returns a substring of the formatted string.

VerifyChar(Char, Int32, MaskedTextResultHint)

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

VerifyEscapeChar(Char, Int32)

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

VerifyString(String, Int32, MaskedTextResultHint)

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

VerifyString(String)

Tests whether the specified string could be set successfully.

Applies to

See also