Export (0) Print
Expand All

MaskedTextProvider Class

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

System.Object
  System.ComponentModel.MaskedTextProvider

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

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

The MaskedTextProvider type exposes the following members.

  NameDescription
Public methodMaskedTextProvider(String)Initializes a new instance of the MaskedTextProvider class using the specified mask.
Public methodMaskedTextProvider(String, Boolean)Initializes a new instance of the MaskedTextProvider class using the specified mask and ASCII restriction value.
Public methodMaskedTextProvider(String, CultureInfo)Initializes a new instance of the MaskedTextProvider class using the specified mask and culture.
Public methodMaskedTextProvider(String, Char, Boolean)Initializes a new instance of the MaskedTextProvider class using the specified mask, password character, and prompt usage value.
Public methodMaskedTextProvider(String, CultureInfo, Boolean)Initializes a new instance of the MaskedTextProvider class using the specified mask, culture, and ASCII restriction value.
Public methodMaskedTextProvider(String, CultureInfo, Char, Boolean)Initializes a new instance of the MaskedTextProvider class using the specified mask, culture, password character, and prompt usage value.
Public methodMaskedTextProvider(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.
Top

  NameDescription
Public propertyAllowPromptAsInputGets a value indicating whether the prompt character should be treated as a valid input character or not.
Public propertyAsciiOnlyGets a value indicating whether the mask accepts characters outside of the ASCII character set.
Public propertyAssignedEditPositionCountGets the number of editable character positions that have already been successfully assigned an input value.
Public propertyAvailableEditPositionCountGets the number of editable character positions in the input mask that have not yet been assigned an input value.
Public propertyCultureGets the culture that determines the value of the localizable separators and placeholders in the input mask.
Public propertyStatic memberDefaultPasswordCharGets the default password character used obscure user input.
Public propertyEditPositionCountGets the number of editable positions in the formatted string.
Public propertyEditPositionsGets a newly created enumerator for the editable positions in the formatted string.
Public propertyIncludeLiteralsGets or sets a value that indicates whether literal characters in the input mask should be included in the formatted string.
Public propertyIncludePromptGets or sets a value indicating whether PromptChar is used to represent the absence of user input when displaying the formatted string.
Public propertyStatic memberInvalidIndexGets the upper bound of the range of invalid indexes.
Public propertyIsPasswordGets or sets a value that determines whether password protection should be applied to the formatted string.
Public propertyItemGets the element at the specified position in the formatted string.
Public propertyLastAssignedPositionGets the index in the mask of the rightmost input character that has been assigned to the mask.
Public propertyLengthGets the length of the mask, absent any mask modifier characters.
Public propertyMaskGets the input mask.
Public propertyMaskCompletedGets a value indicating whether all required inputs have been entered into the formatted string.
Public propertyMaskFullGets a value indicating whether all required and optional inputs have been entered into the formatted string.
Public propertyPasswordCharGets or sets the character to be substituted for the actual input characters.
Public propertyPromptCharGets or sets the character used to represent the absence of user input for all available edit positions.
Public propertyResetOnPromptGets or sets a value that determines how an input character that matches the prompt character should be handled.
Public propertyResetOnSpaceGets or sets a value that determines how a space input character should be handled.
Public propertySkipLiteralsGets or sets a value indicating whether literal character positions in the mask can be overwritten by their same values.
Top

  NameDescription
Public methodAdd(Char)Adds the specified input character to the end of the formatted string.
Public methodAdd(String)Adds the characters in the specified input string to the end of the formatted string.
Public methodAdd(Char, Int32, MaskedTextResultHint)Adds the specified input character to the end of the formatted string, and then outputs position and descriptive information.
Public methodAdd(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.
Public methodClear()Clears all the editable input characters from the formatted string, replacing them with prompt characters.
Public methodClear(MaskedTextResultHint)Clears all the editable input characters from the formatted string, replacing them with prompt characters, and then outputs descriptive information.
Public methodCloneCreates a copy of the current MaskedTextProvider.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodFindAssignedEditPositionFromReturns the position of the first assigned editable position after the specified position using the specified search direction.
Public methodFindAssignedEditPositionInRangeReturns the position of the first assigned editable position between the specified positions using the specified search direction.
Public methodFindEditPositionFromReturns the position of the first editable position after the specified position using the specified search direction.
Public methodFindEditPositionInRangeReturns the position of the first editable position between the specified positions using the specified search direction.
Public methodFindNonEditPositionFromReturns the position of the first non-editable position after the specified position using the specified search direction.
Public methodFindNonEditPositionInRangeReturns the position of the first non-editable position between the specified positions using the specified search direction.
Public methodFindUnassignedEditPositionFromReturns the position of the first unassigned editable position after the specified position using the specified search direction.
Public methodFindUnassignedEditPositionInRangeReturns the position of the first unassigned editable position between the specified positions using the specified search direction.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodStatic memberGetOperationResultFromHintDetermines whether the specified MaskedTextResultHint denotes success or failure.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInsertAt(Char, Int32)Inserts the specified character at the specified position within the formatted string.
Public methodInsertAt(String, Int32)Inserts the specified string at a specified position within the formatted string.
Public methodInsertAt(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.
Public methodInsertAt(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.
Public methodIsAvailablePositionDetermines whether the specified position is available for assignment.
Public methodIsEditPositionDetermines whether the specified position is editable.
Public methodStatic memberIsValidInputCharDetermines whether the specified character is a valid input character.
Public methodStatic memberIsValidMaskCharDetermines whether the specified character is a valid mask character.
Public methodStatic memberIsValidPasswordCharDetermines whether the specified character is a valid password character.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodRemove()Removes the last assigned character from the formatted string.
Public methodRemove(Int32, MaskedTextResultHint)Removes the last assigned character from the formatted string, and then outputs the removal position and descriptive information.
Public methodRemoveAt(Int32)Removes the assigned character at the specified position from the formatted string.
Public methodRemoveAt(Int32, Int32)Removes the assigned characters between the specified positions from the formatted string.
Public methodRemoveAt(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.
Public methodReplace(Char, Int32)Replaces a single character at or beyond the specified position with the specified character value.
Public methodReplace(String, Int32)Replaces a range of editable characters starting at the specified position with the specified string.
Public methodReplace(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.
Public methodReplace(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.
Public methodReplace(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.
Public methodReplace(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.
Public methodSet(String)Sets the formatted string to the specified input string.
Public methodSet(String, Int32, MaskedTextResultHint)Sets the formatted string to the specified input string, and then outputs the removal position and descriptive information.
Public methodToDisplayStringReturns the formatted string in a displayable form.
Public methodToString()Returns the formatted string that includes all the assigned character values. (Overrides Object.ToString().)
Public methodToString(Boolean)Returns the formatted string, optionally including password characters.
Public methodToString(Boolean, Boolean)Returns the formatted string, optionally including prompt and literal characters.
Public methodToString(Int32, Int32)Returns a substring of the formatted string.
Public methodToString(Boolean, Int32, Int32)Returns a substring of the formatted string, optionally including password characters.
Public methodToString(Boolean, Boolean, Int32, Int32)Returns a substring of the formatted string, optionally including prompt and literal characters.
Public methodToString(Boolean, Boolean, Boolean, Int32, Int32)Returns a substring of the formatted string, optionally including prompt, literal, and password characters.
Public methodVerifyCharTests whether the specified character could be set successfully at the specified position.
Public methodVerifyEscapeCharTests whether the specified character would be escaped at the specified position.
Public methodVerifyString(String)Tests whether the specified string could be set successfully.
Public methodVerifyString(String, Int32, MaskedTextResultHint)Tests whether the specified string could be set successfully, and then outputs position and descriptive information.
Top

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.

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.

NoteNote

The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: SharedState. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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