TypeValidationEventArgs.ValidatingType 屬性

定義

取得型別,以便做為驗證格式化輸入字串的依據。

public:
 property Type ^ ValidatingType { Type ^ get(); };
public Type ValidatingType { get; }
public Type? ValidatingType { get; }
member this.ValidatingType : Type
Public ReadOnly Property ValidatingType As Type

屬性值

轉換處理序的目標 Type。 這個型別不得為 null

範例

下列程式碼範例示範此成員的使用。 在此範例中,事件處理常式會報告事件發生次數 MaskedTextBox.TypeValidationCompleted 。 此報告可協助您瞭解事件發生的時間,並可協助您進行偵錯。 若要報告多個事件或經常發生的事件,請考慮將 取代 MessageBox.ShowConsole.WriteLine 為 或將訊息附加至多行 TextBox

若要執行範例程式碼,請將它貼到包含名為 MaskedTextBox1 之型 MaskedTextBox 別實例的專案。 然後,確定事件處理常式與事件相關聯 MaskedTextBox.TypeValidationCompleted

private void MaskedTextBox1_TypeValidationCompleted(Object sender, TypeValidationEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Cancel", e.Cancel );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "IsValidInput", e.IsValidInput );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Message", e.Message );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ReturnValue", e.ReturnValue );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ValidatingType", e.ValidatingType );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "TypeValidationCompleted Event" );
}
Private Sub MaskedTextBox1_TypeValidationCompleted(sender as Object, e as TypeValidationEventArgs) _ 
     Handles MaskedTextBox1.TypeValidationCompleted

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "Cancel", e.Cancel)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "IsValidInput", e.IsValidInput)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Message", e.Message)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ReturnValue", e.ReturnValue)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ValidatingType", e.ValidatingType)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"TypeValidationCompleted Event")

End Sub

備註

只有在 類別的 MaskedTextBox 屬性不是 nullMaskedTextBox.ValidatingType ,才會發生驗證程式。 屬性 ValidatingType 會參考相同的類型,代表轉換程式的目標型別。

適用於

另請參閱