开发者

How to stop TypeValidationCompleted event?

开发者 https://www.devze.com 2023-01-28 09:19 出处:网络
i had included one mas开发者_如何学Cktext box for date. now in mask text boxes TypeValidationCompleted code...


i had included one mas开发者_如何学Cktext 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?"


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
0

精彩评论

暂无评论...
验证码 换一张
取 消