MaskedTextProvider 類別

定義

表示遮罩剖析服務,任何支援遮罩的控制項數目都可以使用它,例如 MaskedTextBox 控制項。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
繼承
MaskedTextProvider
實作

備註

MaskedTextBox 控制項包含遮罩(由常值字元和格式化元素所組成),其會測試所有使用者輸入。The MaskedTextBox control contains a mask, composed of literal characters and formatting elements, that it tests all user input against. Windows Forms 將特定遮罩剖析引擎永久關聯至 MaskedTextBox,而不是將它當做個別的服務,以 MaskedTextProvider 類別表示,這會定義 Mask 屬性檔中所討論的遮罩語言語法。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.

MaskedTextBox 類別的許多成員會將其實作為相關聯 MaskedTextProvider的類似名稱成員。Many of the members of the MaskedTextBox class refer their implementation to similarly named members of the associated MaskedTextProvider. 例如,MaskedTextBox 類別的 MaskedTextBox.PromptChar 屬性會參考 MaskedTextProvider 類別之 PromptChar 的所有存取權。For example, the MaskedTextBox.PromptChar property of the MaskedTextBox class refers all access to the PromptChar of the MaskedTextProvider class.

MaskedTextProvider 所使用的遮罩剖析引擎會在 Microsoft Visual Basic 第6版所包含的遮罩編輯控制項之後進行模型化。The mask-parsing engine used by MaskedTextProvider is modeled after the Masked Edit control included in Microsoft Visual Basic version 6. 其遮罩語言會在 Mask 屬性的檔中說明。Its masking language is described in the documentation for the Mask property.

下列三個不同的字串會與 MaskedTextProvider 類別相關聯。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. 實際上,輸入字串可能是由多個輸入作業組成,包括 AddReplaceInsertAtRemoveIn 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. 不過,輸入字串處理的層面可透過 AllowPromptAsInputAsciiOnlyResetOnPromptResetOnSpace 屬性來取得。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. 這個字串是在 MaskedTextProvider 中設定,而且主要是透過 Mask 屬性來存取。This string is set in the MaskedTextProvider and accessed primarily though the Mask property. 遮罩的特性也可以透過其他成員取得,例如 LengthPasswordCharPromptChar 屬性。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. 您可以使用類別的許多成員來查詢格式化的字串,包括 Item[Int32]LengthLastAssignedPositionMaskFullMaskCompletedFindEditPositionFrom等等。The formatted string can be queried with many members of the class, including Item[Int32], Length, LastAssignedPosition, MaskFull, MaskCompleted, FindEditPositionFrom, and so on. 格式化字串的完整值可從 ToDisplayStringToString 方法中取得。The full value of the formatted string is available from the ToDisplayString and ToString methods.

注意

輸入字串可能代表直接使用者輸入,如同 MaskedTextBox的情況,或可能由不直接與使用者輸入/輸出作業相關聯的其他進程所產生。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.

建構函式

MaskedTextProvider(String)

使用指定的遮罩,初始化 MaskedTextProvider 類別的新執行個體。Initializes a new instance of the MaskedTextProvider class using the specified mask.

MaskedTextProvider(String, Boolean)

使用指定的遮罩和 ASCII 限制值,初始化 MaskedTextProvider 類別的新執行個體。Initializes a new instance of the MaskedTextProvider class using the specified mask and ASCII restriction value.

MaskedTextProvider(String, Char, Boolean)

使用指定的遮罩、密碼字元和提示使用值,初始化 MaskedTextProvider 類別的新執行個體。Initializes a new instance of the MaskedTextProvider class using the specified mask, password character, and prompt usage value.

MaskedTextProvider(String, CultureInfo)

使用指定的遮罩和文化特性,初始化 MaskedTextProvider 類別的新執行個體。Initializes a new instance of the MaskedTextProvider class using the specified mask and culture.

MaskedTextProvider(String, CultureInfo, Boolean)

使用指定的遮罩、文化特性和 ASCII 限制值,初始化 MaskedTextProvider 類別的新執行個體。Initializes a new instance of the MaskedTextProvider class using the specified mask, culture, and ASCII restriction value.

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

使用指定的遮罩、文化特性、提示使用值、提示字元、密碼字元和 ASCII 限制值,初始化 MaskedTextProvider 類別的新執行個體。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 類別的新執行個體。Initializes a new instance of the MaskedTextProvider class using the specified mask, culture, password character, and prompt usage value.

屬性

AllowPromptAsInput

取得值,指出提示字元是否應視為有效輸入字元。Gets a value indicating whether the prompt character should be treated as a valid input character or not.

AsciiOnly

取得值,指出遮罩是否接受 ASCII 字元集之外的字元。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

取得或設定值,指出 PromptChar 是否用來表示,在顯示格式化字串時使用者輸入項目不存在。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.

方法

Add(Char)

將指定的輸入字元加入至格式化字串的結尾。Adds the specified input character to the end of the formatted string.

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)

將指定輸入字串的字元加入至格式化字串的結尾。Adds the characters in the specified input string 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.

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()

建立目前的 MaskedTextProvider 複本。Creates a copy of the current MaskedTextProvider.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 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.

(繼承來源 Object)
GetOperationResultFromHint(MaskedTextResultHint)

判斷指定的 MaskedTextResultHint 代表成功或失敗。Determines whether the specified MaskedTextResultHint denotes success or failure.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
InsertAt(Char, Int32)

在格式化字串中的指定位置插入指定字元。Inserts the specified character at the specified position within the formatted string.

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)

在格式化字串中的指定位置插入指定字串。Inserts the specified string at a 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.

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()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 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)

移除格式化字串中指定位置上的指定字元。Removes the assigned character at the specified position from the formatted string.

RemoveAt(Int32, Int32)

移除格式化字串中指定位置之間的指定字元。Removes the assigned characters between the specified positions from the formatted string.

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)

將指定位置或之外的單一字元取代成指定字元值。Replaces a single character at or beyond the specified position with the specified character value.

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

從指定的位置開始,將可編輯的字元範圍取代成指定字串。Replaces a range of editable characters starting at the specified position with the specified string.

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.

Set(String)

將格式化字串設為指定的輸入字串。Sets the formatted string to the specified input string.

Set(String, Int32, MaskedTextResultHint)

將格式化字串設為指定的輸入字串,然後輸出移除位置和描述性資訊。Sets the formatted string to the specified input string, and then outputs the removal position and descriptive information.

ToDisplayString()

用可顯示格式傳回格式化字串。Returns the formatted string in a displayable form.

ToString()

傳回格式化字串,包含所有指定的字元值。Returns the formatted string that includes all the assigned character values.

ToString(Boolean)

傳回格式化字串,選擇性包含密碼字元。Returns the formatted string, optionally including password characters.

ToString(Boolean, Boolean)

傳回格式化字串,選擇性包含提示和常值字元。Returns the formatted string, optionally including prompt and literal characters.

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, Int32, Int32)

傳回格式化字串的子字串,選擇性包含密碼字元。Returns a substring of 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)

測試是否可以成功設定指定的字串。Tests whether the specified string could be set successfully.

VerifyString(String, Int32, MaskedTextResultHint)

測試是否可以成功設定指定的字串,然後輸出位置和描述性資訊。Tests whether the specified string could be set successfully, and then outputs position and descriptive information.

適用於

另請參閱