how to prevent duplicated in combobox....

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
 
S

Supra

i found this newsgroup...
i solved it:
it is item(i) instead of ComboBox1.SelectedItem

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

regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top