I have decided to add some validation to my combobox, what I'm trying to achieve is to make sure that the user can ONLY enter fields that are in the combobox but the problem I have now is that if the user clicks on the combobox and doesnt enter anything and tries to leave the combobox the message box appears.
Private Sub Combobox1_Validating(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles Combobox1.Validating
If Combobox1.Items.Contains(Combobox1.Text) = False Then
e.Cancel = True
End If
End Sub
Private Sub Combobox1_Leave(sender As Object, e As System.EventArgs) Handles Combobox1.Leave
If Combobox1.Items.Contains(Combobox1.Text) = False Then
Combobox1.Select()
MessageBox.Show("select item from combobox")
End If
End Sub
As stated before the coding does work, but I was trying to make sure the message box does not appear if the user doesnt enter anything in the combobox.