如何停止 TypeValidationCompleted 事件?
我已经添加了一个日期掩码文本框。
现在在掩码文本框中 TypeValidationCompleted 代码...
If (Not e.IsValidInput) Then
MsgBox("The data you supplied must be a valid date.", MsgBoxStyle.Critical, "Date Error")
tdatemask.Text = ""
tdatemask.Focus()
End If
现在,当我尝试通过按表单的关闭按钮退出表单时,也会发生此事件。
现在我的问题是“当我们尝试退出表单时如何停止此事件?”
i had included one masktext box for date.
now in mask text boxes TypeValidationCompleted code...
If (Not e.IsValidInput) Then
MsgBox("The data you supplied must be a valid date.", MsgBoxStyle.Critical, "Date Error")
tdatemask.Text = ""
tdatemask.Focus()
End If
now when i try to exit the form by pressing close button of form then also this event is occurring.
now my question is "how to stop this event while we try to exit the form?"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以设置一个标志,然后当validationcompleted事件开始时您检查该标志,如果设置为true(意味着表单正在关闭)您可以让它忽略检查。
EX: _formClosing 将是一个全局布尔值,在表单关闭事件期间设置为 true。
You can set a flag and then when the validationcompleted event kicks off you check for the flag, if set to true (meaning the form is closing) you can have it ignore the check.
EX: _formClosing would be a global boolean that is set to true during form closing event.