Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

How to stop firing Leave event twice?

$
0
0
I am cheking validity of data in leave event. If data is not OK I ask user to change it or cancel it and move on. But when user select to move on to another control same event fires again. How do I stop it? Here is my code:

Private Sub TextBoxClientId_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UcTextBoxClientId.Leave
TextBoxClientId.Text = TextBoxClientId.Text.Trim()
If TextBoxClientId.Text.Length = 0 Then 'No need to check anything when it is empty
Exit Sub
End If
If IsDuplicate(TextBoxClientId.Text) Then
If MessageBox.Show("Client already in the System" & Chr(13) & "Do you want to add another client?", _
"Client not Found", MessageBoxButtons.YesNo, MessageBoxIcon.Stop) = Windows.Forms.DialogResult.Yes Then
TextBoxClientId.Focus()
Else
NextControl.Focus()
End If
Exit Sub
End If
End Sub

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>