MaskedTextProvider MaskedTextProvider MaskedTextProvider 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
MaskedTextProviderMaskedTextProviderMaskedTextProviderMaskedTextProvider
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[Int32], 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) MaskedTextProvider(String) MaskedTextProvider(String) MaskedTextProvider(String)

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

MaskedTextProvider(String, Boolean) MaskedTextProvider(String, Boolean) MaskedTextProvider(String, Boolean) MaskedTextProvider(String, Boolean)

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

MaskedTextProvider(String, Char, Boolean) MaskedTextProvider(String, Char, Boolean) MaskedTextProvider(String, Char, Boolean) 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) MaskedTextProvider(String, CultureInfo) MaskedTextProvider(String, CultureInfo) MaskedTextProvider(String, CultureInfo)

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

MaskedTextProvider(String, CultureInfo, Boolean) MaskedTextProvider(String, CultureInfo, Boolean) MaskedTextProvider(String, CultureInfo, Boolean) MaskedTextProvider(String, CultureInfo, Boolean)

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

MaskedTextProvider(String, CultureInfo, Boolean, Char, Char, Boolean) MaskedTextProvider(String, CultureInfo, Boolean, Char, Char, Boolean) MaskedTextProvider(String, CultureInfo, Boolean, Char, Char, Boolean) 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, Char, Boolean) MaskedTextProvider(String, CultureInfo, Char, Boolean) MaskedTextProvider(String, CultureInfo, Char, Boolean) MaskedTextProvider(String, CultureInfo, Char, Boolean)

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

Properties

AllowPromptAsInput AllowPromptAsInput AllowPromptAsInput AllowPromptAsInput

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

AsciiOnly AsciiOnly AsciiOnly AsciiOnly

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

AssignedEditPositionCount AssignedEditPositionCount AssignedEditPositionCount AssignedEditPositionCount

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

AvailableEditPositionCount AvailableEditPositionCount AvailableEditPositionCount AvailableEditPositionCount

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

Culture Culture Culture Culture

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

DefaultPasswordChar DefaultPasswordChar DefaultPasswordChar DefaultPasswordChar

Gets the default password character used obscure user input.

EditPositionCount EditPositionCount EditPositionCount EditPositionCount

Gets the number of editable positions in the formatted string.

EditPositions EditPositions EditPositions EditPositions

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

IncludeLiterals IncludeLiterals IncludeLiterals IncludeLiterals

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

IncludePrompt IncludePrompt IncludePrompt IncludePrompt

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

InvalidIndex InvalidIndex InvalidIndex InvalidIndex

Gets the upper bound of the range of invalid indexes.

IsPassword IsPassword IsPassword IsPassword

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

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

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

LastAssignedPosition LastAssignedPosition LastAssignedPosition LastAssignedPosition

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

Length Length Length Length

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

Mask Mask Mask Mask

Gets the input mask.

MaskCompleted MaskCompleted MaskCompleted MaskCompleted

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

MaskFull MaskFull MaskFull MaskFull

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

PasswordChar PasswordChar PasswordChar PasswordChar

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

PromptChar PromptChar PromptChar PromptChar

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

ResetOnPrompt ResetOnPrompt ResetOnPrompt ResetOnPrompt

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

ResetOnSpace ResetOnSpace ResetOnSpace ResetOnSpace

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

SkipLiterals SkipLiterals SkipLiterals SkipLiterals

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

Methods

Add(Char) Add(Char) Add(Char) Add(Char)

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

Add(Char, Int32, MaskedTextResultHint) Add(Char, Int32, MaskedTextResultHint) Add(Char, Int32, MaskedTextResultHint) Add(Char, Int32, MaskedTextResultHint)

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

Add(String) Add(String) Add(String) Add(String)

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

Add(String, Int32, MaskedTextResultHint) Add(String, Int32, MaskedTextResultHint) Add(String, Int32, MaskedTextResultHint) 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.

Clear() Clear() Clear() Clear()

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

Clear(MaskedTextResultHint) Clear(MaskedTextResultHint) Clear(MaskedTextResultHint) Clear(MaskedTextResultHint)

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

Clone() Clone() Clone() Clone()

Creates a copy of the current MaskedTextProvider.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
FindAssignedEditPositionFrom(Int32, Boolean) FindAssignedEditPositionFrom(Int32, Boolean) FindAssignedEditPositionFrom(Int32, Boolean) 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) FindAssignedEditPositionInRange(Int32, Int32, Boolean) FindAssignedEditPositionInRange(Int32, Int32, Boolean) 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) FindEditPositionFrom(Int32, Boolean) FindEditPositionFrom(Int32, Boolean) FindEditPositionFrom(Int32, Boolean)

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

FindEditPositionInRange(Int32, Int32, Boolean) FindEditPositionInRange(Int32, Int32, Boolean) FindEditPositionInRange(Int32, Int32, Boolean) FindEditPositionInRange(Int32, Int32, Boolean)

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

FindNonEditPositionFrom(Int32, Boolean) FindNonEditPositionFrom(Int32, Boolean) FindNonEditPositionFrom(Int32, Boolean) 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) FindNonEditPositionInRange(Int32, Int32, Boolean) FindNonEditPositionInRange(Int32, Int32, Boolean) 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) FindUnassignedEditPositionFrom(Int32, Boolean) FindUnassignedEditPositionFrom(Int32, Boolean) 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) FindUnassignedEditPositionInRange(Int32, Int32, Boolean) FindUnassignedEditPositionInRange(Int32, Int32, Boolean) FindUnassignedEditPositionInRange(Int32, Int32, Boolean)

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

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetOperationResultFromHint(MaskedTextResultHint) GetOperationResultFromHint(MaskedTextResultHint) GetOperationResultFromHint(MaskedTextResultHint) GetOperationResultFromHint(MaskedTextResultHint)

Determines whether the specified MaskedTextResultHint denotes success or failure.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
InsertAt(Char, Int32) InsertAt(Char, Int32) InsertAt(Char, Int32) InsertAt(Char, Int32)

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

InsertAt(Char, Int32, Int32, MaskedTextResultHint) InsertAt(Char, Int32, Int32, MaskedTextResultHint) InsertAt(Char, Int32, Int32, MaskedTextResultHint) 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(String, Int32) InsertAt(String, Int32) InsertAt(String, Int32) InsertAt(String, Int32)

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

InsertAt(String, Int32, Int32, MaskedTextResultHint) InsertAt(String, Int32, Int32, MaskedTextResultHint) InsertAt(String, Int32, Int32, MaskedTextResultHint) 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.

IsAvailablePosition(Int32) IsAvailablePosition(Int32) IsAvailablePosition(Int32) IsAvailablePosition(Int32)

Determines whether the specified position is available for assignment.

IsEditPosition(Int32) IsEditPosition(Int32) IsEditPosition(Int32) IsEditPosition(Int32)

Determines whether the specified position is editable.

IsValidInputChar(Char) IsValidInputChar(Char) IsValidInputChar(Char) IsValidInputChar(Char)

Determines whether the specified character is a valid input character.

IsValidMaskChar(Char) IsValidMaskChar(Char) IsValidMaskChar(Char) IsValidMaskChar(Char)

Determines whether the specified character is a valid mask character.

IsValidPasswordChar(Char) IsValidPasswordChar(Char) IsValidPasswordChar(Char) IsValidPasswordChar(Char)

Determines whether the specified character is a valid password character.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Remove() Remove() Remove() Remove()

Removes the last assigned character from the formatted string.

Remove(Int32, MaskedTextResultHint) Remove(Int32, MaskedTextResultHint) Remove(Int32, MaskedTextResultHint) Remove(Int32, MaskedTextResultHint)

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

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

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

RemoveAt(Int32, Int32) RemoveAt(Int32, Int32) RemoveAt(Int32, Int32) RemoveAt(Int32, Int32)

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

RemoveAt(Int32, Int32, Int32, MaskedTextResultHint) RemoveAt(Int32, Int32, Int32, MaskedTextResultHint) RemoveAt(Int32, Int32, Int32, MaskedTextResultHint) 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.

Replace(Char, Int32) Replace(Char, Int32) Replace(Char, Int32) Replace(Char, Int32)

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

Replace(Char, Int32, Int32, Int32, MaskedTextResultHint) Replace(Char, Int32, Int32, Int32, MaskedTextResultHint) Replace(Char, Int32, Int32, Int32, MaskedTextResultHint) 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) Replace(Char, Int32, Int32, MaskedTextResultHint) Replace(Char, Int32, Int32, MaskedTextResultHint) 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(String, Int32) Replace(String, Int32) Replace(String, Int32) Replace(String, Int32)

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

Replace(String, Int32, Int32, Int32, MaskedTextResultHint) Replace(String, Int32, Int32, Int32, MaskedTextResultHint) Replace(String, Int32, Int32, Int32, MaskedTextResultHint) 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) Replace(String, Int32, Int32, MaskedTextResultHint) Replace(String, Int32, Int32, MaskedTextResultHint) 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.

Set(String) Set(String) Set(String) Set(String)

Sets the formatted string to the specified input string.

Set(String, Int32, MaskedTextResultHint) Set(String, Int32, MaskedTextResultHint) Set(String, Int32, MaskedTextResultHint) Set(String, Int32, MaskedTextResultHint)

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

ToDisplayString() ToDisplayString() ToDisplayString() ToDisplayString()

Returns the formatted string in a displayable form.

ToString() ToString() ToString() ToString()

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

ToString(Boolean) ToString(Boolean) ToString(Boolean) ToString(Boolean)

Returns the formatted string, optionally including password characters.

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

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

ToString(Boolean, Boolean, Boolean, Int32, Int32) ToString(Boolean, Boolean, Boolean, Int32, Int32) ToString(Boolean, Boolean, Boolean, Int32, Int32) 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) ToString(Boolean, Boolean, Int32, Int32) ToString(Boolean, Boolean, Int32, Int32) ToString(Boolean, Boolean, Int32, Int32)

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

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

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

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

Returns a substring of the formatted string.

VerifyChar(Char, Int32, MaskedTextResultHint) VerifyChar(Char, Int32, MaskedTextResultHint) VerifyChar(Char, Int32, MaskedTextResultHint) VerifyChar(Char, Int32, MaskedTextResultHint)

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

VerifyEscapeChar(Char, Int32) VerifyEscapeChar(Char, Int32) VerifyEscapeChar(Char, Int32) VerifyEscapeChar(Char, Int32)

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

VerifyString(String) VerifyString(String) VerifyString(String) VerifyString(String)

Tests whether the specified string could be set successfully.

VerifyString(String, Int32, MaskedTextResultHint) VerifyString(String, Int32, MaskedTextResultHint) VerifyString(String, Int32, MaskedTextResultHint) VerifyString(String, Int32, MaskedTextResultHint)

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

Applies to

See Also