1,105,208 Community Members

how add items in combo box but without repetition

Member Avatar
angel392004
Newbie Poster
13 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

guys help me with the code for adding items in the combo box but without duplicates. i have an assignment which is a simple web browser. the combo box will be the address bar. and everytime i input an address, it will be added in combo box and should not repeat just like in the browsers. i hope you could help me. thanks

Unhnd_Exception
Deleted Member
 
0
 

ComboBox.FindString will return the index of an item that matches.

See if this helps.

If combox1.FindString("The String To Search") < 0 Then
            combox1.Items.Add("The String To Search")
        End If
yansthais
Newbie Poster
1 post since Jun 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

Thanks for your valuable sharing of combobox add items.

Member Avatar
Reverend Jim
Noli mentula
5,392 posts since Aug 2010
Reputation Points: 744 [?]
Q&As Helped to Solve: 643 [?]
Skill Endorsements: 51 [?]
Moderator
Featured
 
0
 

The following will add "some text" to the combo box only if it doesn't already exist.

Dim text As String = "some text"

If Not ComboBox1.Items.Contains(text) Then
    ComboBox1.Items.Add(text)
End If
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: