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:
Private Sub ValidateComboItem(ByVal comboName As ComboBox) Dim comparetext As String If Not comboName.Text = String.Empty Then Dim ItemFound As Boolean = False For i As Integer = 0 To comboName.Items.Count - 1 If comboName.Items(i).ToString = comboName.Text Then ItemFound = True End If Next If Not ItemFound = True Then comboName.Text = String.Empty ErrorProvider1.SetError(comboName, "Value cannot find from list") Else ErrorProvider1.SetError(comboName, Nothing) End If ItemFound = False End If End Sub




Reply With Quote