This topic has not yet been rated - Rate this topic

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.

  Name Description
Public method MaskedTextProvider(String) Initializes a new instance of the MaskedTextProvider class using the specified mask.
Public method MaskedTextProvider(String, Boolean) Initializes a new instance of the MaskedTextProvider class using the specified mask and ASCII restriction value.
Public method MaskedTextProvider(String, CultureInfo) Initializes a new instance of the MaskedTextProvider class using the specified mask and culture.
Public method MaskedTextProvider(String, Char, Boolean) Initializes a new instance of the MaskedTextProvider class using the specified mask, password character, and prompt usage value.
Public method MaskedTextProvider(String, CultureInfo, Boolean) Initializes a new instance of the MaskedTextProvider class using the specified mask, culture, and ASCII restriction value.
Public method MaskedTextProvider(String, CultureInfo, Char, Boolean) Initializes a new instance of the MaskedTextProvider class using the specified mask, culture, password character, and prompt usage value.
Public method 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.
Top
  Name Description
Public property AllowPromptAsInput Gets a value indicating whether the prompt character should be treated as a valid input character or not.
Public property AsciiOnly Gets a value indicating whether the mask accepts characters outside of the ASCII character set.
Public property AssignedEditPositionCount Gets the number of editable character positions that have already been successfully assigned an input value.
Public property AvailableEditPositionCount Gets the number of editable character positions in the input mask that have not yet been assigned an input value.
Public property Culture Gets the culture that determines the value of the localizable separators and placeholders in the input mask.
Public property Static member DefaultPasswordChar Gets the default password character used obscure user input.
Public property EditPositionCount Gets the number of editable positions in the formatted string.
Public property EditPositions Gets a newly created enumerator for the editable positions in the formatted string.
Public property IncludeLiterals Gets or sets a value that indicates whether literal characters in the input mask should be included in the formatted string.
Public property IncludePrompt Gets or sets a value indicating whether PromptChar is used to represent the absence of user input when displaying the formatted string.
Public property Static member InvalidIndex Gets the upper bound of the range of invalid indexes.
Public property IsPassword Gets or sets a value that determines whether password protection should be applied to the formatted string.
Public property Item Gets the element at the specified position in the formatted string.
Public property LastAssignedPosition Gets the index in the mask of the rightmost input character that has been assigned to the mask.
Public property Length Gets the length of the mask, absent any mask modifier characters.
Public property Mask Gets the input mask.
Public property MaskCompleted Gets a value indicating whether all required inputs have been entered into the formatted string.
Public property MaskFull Gets a value indicating whether all required and optional inputs have been entered into the formatted string.
Public property PasswordChar Gets or sets the character to be substituted for the actual input characters.
Public property PromptChar Gets or sets the character used to represent the absence of user input for all available edit positions.
Public property ResetOnPrompt Gets or sets a value that determines how an input character that matches the prompt character should be handled.
Public property ResetOnSpace Gets or sets a value that determines how a space input character should be handled.
Public property SkipLiterals Gets or sets a value indicating whether literal character positions in the mask can be overwritten by their same values.
Top
  Name Description
Public method Add(Char) Adds the specified input character to the end of the formatted string.
Public method Add(String) Adds the characters in the specified input string to the end of the formatted string.
Public method Add(Char, Int32, MaskedTextResultHint) Adds the specified input character to the end of the formatted string, and then outputs position and descriptive information.
Public method 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.
Public method Clear() Clears all the editable input characters from the formatted string, replacing them with prompt characters.
Public method Clear(MaskedTextResultHint) Clears all the editable input characters from the formatted string, replacing them with prompt characters, and then outputs descriptive information.
Public method Clone Creates a copy of the current MaskedTextProvider.
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method FindAssignedEditPositionFrom Returns the position of the first assigned editable position after the specified position using the specified search direction.
Public method FindAssignedEditPositionInRange Returns the position of the first assigned editable position between the specified positions using the specified search direction.
Public method FindEditPositionFrom Returns the position of the first editable position after the specified position using the specified search direction.
Public method FindEditPositionInRange Returns the position of the first editable position between the specified positions using the specified search direction.
Public method FindNonEditPositionFrom Returns the position of the first non-editable position after the specified position using the specified search direction.
Public method FindNonEditPositionInRange Returns the position of the first non-editable position between the specified positions using the specified search direction.
Public method FindUnassignedEditPositionFrom Returns the position of the first unassigned editable position after the specified position using the specified search direction.
Public method FindUnassignedEditPositionInRange Returns the position of the first unassigned editable position between the specified positions using the specified search direction.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method Static member GetOperationResultFromHint Determines whether the specified MaskedTextResultHint denotes success or failure.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method InsertAt(Char, Int32) Inserts the specified character at the specified position within the formatted string.
Public method InsertAt(String, Int32) Inserts the specified string at a specified position within the formatted string.
Public method 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.
Public method 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.
Public method IsAvailablePosition Determines whether the specified position is available for assignment.
Public method IsEditPosition Determines whether the specified position is editable.
Public method Static member IsValidInputChar Determines whether the specified character is a valid input character.
Public method Static member IsValidMaskChar Determines whether the specified character is a valid mask character.
Public method Static member IsValidPasswordChar Determines whether the specified character is a valid password character.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Remove() Removes the last assigned character from the formatted string.
Public method Remove(Int32, MaskedTextResultHint) Removes the last assigned character from the formatted string, and then outputs the removal position and descriptive information.
Public method RemoveAt(Int32) Removes the assigned character at the specified position from the formatted string.
Public method RemoveAt(Int32, Int32) Removes the assigned characters between the specified positions from the formatted string.
Public method 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.
Public method Replace(Char, Int32) Replaces a single character at or beyond the specified position with the specified character value.
Public method Replace(String, Int32) Replaces a range of editable characters starting at the specified position with the specified string.
Public method 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.
Public method 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.
Public method 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.
Public method 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.
Public method Set(String) Sets the formatted string to the specified input string.
Public method Set(String, Int32, MaskedTextResultHint) Sets the formatted string to the specified input string, and then outputs the removal position and descriptive information.
Public method ToDisplayString Returns the formatted string in a displayable form.
Public method ToString() Returns the formatted string that includes all the assigned character values. (Overrides Object.ToString().)
Public method ToString(Boolean) Returns the formatted string, optionally including password characters.
Public method ToString(Boolean, Boolean) Returns the formatted string, optionally including prompt and literal characters.
Public method ToString(Int32, Int32) Returns a substring of the formatted string.
Public method ToString(Boolean, Int32, Int32) Returns a substring of the formatted string, optionally including password characters.
Public method ToString(Boolean, Boolean, Int32, Int32) Returns a substring of the formatted string, optionally including prompt and literal characters.
Public method ToString(Boolean, Boolean, Boolean, Int32, Int32) Returns a substring of the formatted string, optionally including prompt, literal, and password characters.
Public method VerifyChar Tests whether the specified character could be set successfully at the specified position.
Public method VerifyEscapeChar Tests whether the specified character would be escaped at the specified position.
Public method VerifyString(String) Tests whether the specified string could be set successfully.
Public method VerifyString(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.

Note 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.

Note Note

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, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ