通过


TypeValidationEventArgs.Message 属性

定义

获取描述转换过程的文本消息。

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

属性值

String包含转换过程的说明。

示例

下面的代码示例演示了此成员的使用。 在此示例中,事件处理程序报告事件的发生情况 MaskedTextBox.TypeValidationCompleted 。 此报告可帮助你了解事件发生的时间,并可以帮助你进行调试。 若要报告多个事件或频繁发生的事件,请考虑替换MessageBox.ShowConsole.WriteLine或将消息追加到多行TextBox

若要运行示例代码,请将其粘贴到包含命名MaskedTextBox类型的MaskedTextBox1实例的项目中。 然后,确保事件处理程序与 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 类型。 该 Message 属性包含转换过程的文本说明。 Message转换失败时,主要有用,如属性值false所示IsValidInput

适用于

另请参阅