TypeValidationEventArgs.ReturnValue 屬性

定義

取得格式化輸入字串之轉換所產生的物件。

public:
 property System::Object ^ ReturnValue { System::Object ^ get(); };
public object ReturnValue { get; }
public object? ReturnValue { get; }
member this.ReturnValue : obj
Public ReadOnly Property ReturnValue As Object

屬性值

如果驗證成功,則為表示轉換型別的 Object,否則為 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

備註

類型驗證程式會嘗試將格式化的輸入字串,不包括提示字元轉換為 屬性所 ValidatingType 指定的類型。 屬性 ReturnValue 代表轉換嘗試的結果,相當於 類別的 方法 MaskedTextBoxValidateText 傳回的值。

適用於

另請參閱