TypeValidationEventArgs.ReturnValue 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得格式化輸入字串之轉換所產生的物件。
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 代表轉換嘗試的結果,相當於 類別的 方法 MaskedTextBox 所 ValidateText 傳回的值。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應