i had included one mas开发者_如何学Cktext box for date.
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?"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.
If (Not e.IsValidInput) and (Not _formClosing) Then
MsgBox("The data you supplied must be a valid date.", MsgBoxStyle.Critical, "Date Error")
tdatemask.Text = ""
tdatemask.Focus()
End If
精彩评论