TypeValidationEventArgs.Message Właściwość

Definicja

Pobiera komunikat tekstowy opisujący proces konwersji.

public:
 property System::String ^ Message { System::String ^ get(); };
public string Message { get; }
public string? Message { get; }
member this.Message : string
Public ReadOnly Property Message As String

Wartość właściwości

Element String zawierający opis procesu konwersji.

Przykłady

Poniższy przykład kodu przedstawia użycie tego elementu członkowskiego. W tym przykładzie program obsługi zdarzeń zgłasza wystąpienie zdarzenia MaskedTextBox.TypeValidationCompleted . Ten raport pomaga dowiedzieć się, kiedy wystąpi zdarzenie i może pomóc w debugowaniu. Aby zgłosić wiele zdarzeń lub zdarzeń, które występują często, rozważ zastąpienie MessageBox.Show komunikatu ciągiem Console.WriteLine lub dołączeniem 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 weryfikacji wiąże się z konwertowaniem sformatowanych danych wejściowych użytkownika na typ zdefiniowany przez ValidatingType właściwość. Właściwość Message zawiera opis tekstowy procesu konwersji. Messagejest przede wszystkim przydatne, gdy konwersja kończy się niepowodzeniemIsValidInput, co wskazuje wartość właściwości .false

Dotyczy

Zobacz też