TypeValidationEventArgs 类

定义

TypeValidationCompleted 事件提供数据。Provides data for the TypeValidationCompleted event.

public ref class TypeValidationEventArgs : EventArgs
public class TypeValidationEventArgs : EventArgs
type TypeValidationEventArgs = class
    inherit EventArgs
Public Class TypeValidationEventArgs
Inherits EventArgs
继承
TypeValidationEventArgs

示例

下面的代码示例演示如何使用此类型。The following code example demonstrates the use of this type. 在此示例中, 事件处理程序报告TypeValidationCompleted事件的发生。In the example, an event handler reports on the occurrence of the TypeValidationCompleted event. 此报表可帮助你了解何时发生事件, 并可帮助你进行调试。This report helps you to learn when the event occurs and can assist you in debugging. 若要报告多个事件或频繁发生的事件, 请考虑ShowConsole.WriteLine消息替换为多行或将TextBox其追加到多行。To report on multiple events or on events that occur frequently, consider replacing Show with Console.WriteLine or appending the message to a multiline TextBox.

若要运行示例代码, 请将其粘贴到包含名为MaskedTextBox MaskedTextBox1的类型的实例的项目中。To run the example code, paste it into a project that contains an instance of type MaskedTextBox named MaskedTextBox1. 然后, 确保事件处理程序与TypeValidationCompleted事件相关联。Then ensure that the event handler is associated with the TypeValidationCompleted event.

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

注解

当控件执行可选类型验证时发生此TypeValidationCompleted事件。 MaskedTextBoxThe TypeValidationCompleted event occurs when a MaskedTextBox control performs optional type validation. 仅当MaskedTextBox.ValidatingType属性不null为, 并且发生因果操作 (如失去焦点的MaskedTextBox控件) 时, 才会发生类型验证。Type validation occurs only when the MaskedTextBox.ValidatingType property is not null and a causal action occurs, such as the MaskedTextBox control losing focus. 类型验证是将格式化输入字符串转换为ValidatingType属性表示的类型的能力。Type validation is the ability to convert the formatted input string to the type represented by the ValidatingType property. 有关类型验证过程的详细信息, 请参阅TypeValidationCompleted事件。For more information about the type validation process, see the TypeValidationCompleted event.

如果为TypeValidationCompleted实现了事件处理程序, 则处理程序将接收类型TypeValidationEventArgs为的参数。If an event handler is implemented for TypeValidationCompleted, the handler receives a parameter of type TypeValidationEventArgs. 此参数包含有关事件的信息, 例如类型转换过程是否成功、验证类型等。This parameter contains information about the event, such as whether the type conversion process succeeded, the validating type, and so on.

构造函数

TypeValidationEventArgs(Type, Boolean, Object, String)

初始化 TypeValidationEventArgs 类的新实例。Initializes a new instance of the TypeValidationEventArgs class.

属性

Cancel

获取或设置指示是否应取消事件的值。Gets or sets a value indicating whether the event should be canceled.

IsValidInput

获取一个值,该值指示格式化输入字符串是否成功转换为验证类型。Gets a value indicating whether the formatted input string was successfully converted to the validating type.

Message

获取描述转换过程的文本消息。Gets a text message describing the conversion process.

ReturnValue

获取格式化输入字符串转换所生成的对象。Gets the object that results from the conversion of the formatted input string.

ValidatingType

获取格式化输入字符串的验证目标类型。Gets the type that the formatted input string is being validated against.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅