how to prevent duplicated in combobox....

  • Thread starter Thread starter Supra
  • Start date Start date
S

Supra

How do i prevent duplicated in combobox ?
Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
If Asc(e.KeyChar) = Keys.Enter Then
AxWebBrowser1.Navigate(ComboBox1.Text)

Dim bFound As Boolean
bFound = False
For i As Integer = 0 To
ComboBox1.Items.Count - 1
If ComboBox1.SelectedItem = ComboBox1.Text Then
bFound = True
Exit For
End If
Next
If bFound = False Then
ComboBox1.Items.Add(ComboBox1.Text.ToString)
End If
End If
End Sub
 
i found this newsgroup...
i solved it:
it is item(i) instead of ComboBox1.SelectedItem

If ComboBox1.Items(i) = ComboBox1.Text Then

regards,
 
Back
Top