TypeValidationEventArgs.ReturnValue Właściwość

Definicja

Pobiera obiekt, który wynika z konwersji sformatowanego ciągu wejściowego.

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

Wartość właściwości

Jeśli walidacja zakończy się pomyślnie, element Object reprezentujący przekonwertowany typ; w przeciwnym razie . null

Przykłady

W poniższym przykładzie kodu pokazano użycie tego elementu członkowskiego. W tym przykładzie program obsługi zdarzeń zgłasza wystąpienie MaskedTextBox.TypeValidationCompleted zdarzenia. Ten raport pomaga dowiedzieć się, kiedy wystąpi zdarzenie, i może pomóc w debugowaniu. Aby zgłosić wiele zdarzeń lub często występujących zdarzeń, rozważ zastąpienie MessageBox.Show komunikatu ciągiem Console.WriteLine lub dołączenie go do wielowierszowego TextBoxelementu .

Aby uruchomić przykładowy kod, wklej go w projekcie zawierającym wystąpienie typu MaskedTextBox o nazwie MaskedTextBox1. Następnie upewnij się, że program obsługi zdarzeń jest skojarzony ze zdarzeniem 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

Uwagi

Proces sprawdzania poprawności typu próbuje przekonwertować sformatowany ciąg wejściowy, w tym znaki monitu ValidatingType , na typ określony przez właściwość. Właściwość ReturnValue reprezentuje wynik próby konwersji i jest równoważna wartości zwracanej przez ValidateText metodę MaskedTextBox klasy.

Dotyczy

Zobacz też