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.Show 替换为 Console.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 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈