I would like to make a validation on my combobox,
i don't want to set combobox dropdownstyle to dropdownlist because dropdownlist unabled to let user find work inside the list by typing.

if user select the list do not contains on list. the combobox will became empty and errorprovider pop up.

thanksss


vb Code:
  1. Private Sub ValidateComboItem(ByVal comboName As ComboBox)
  2.         Dim comparetext As String
  3.         If Not comboName.Text = String.Empty Then
  4.             Dim ItemFound As Boolean = False
  5.             For i As Integer = 0 To comboName.Items.Count - 1
  6.  
  7.  
  8.                 If comboName.Items(i).ToString = comboName.Text Then
  9.                     ItemFound = True
  10.                 End If
  11.             Next
  12.             If Not ItemFound = True Then
  13.                 comboName.Text = String.Empty
  14.                 ErrorProvider1.SetError(comboName, "Value cannot find from list")
  15.             Else
  16.                 ErrorProvider1.SetError(comboName, Nothing)
  17.             End If
  18.             ItemFound = False
  19.         End If
  20.  End Sub