Click here to Skip to main content
16,020,186 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello and good day !

I'm using vb.net, I have something like this :
VB
If textbox1.Text = "abc" Then
     ddl1.Items.Add(1)
     ddl1.Items.Add(2)
     ddl1.Items.Remove(3)
     ddl1.Items.remove(4)
End If

If textbox1.Text = "efg" Then
     ddl1.Items.Add(3)
     ddl1.Items.Add(4)
     ddl.Items.Remove(1)
     ddl.Items.Remove(2)
End If

How I'm going to make when I key-in "abc" more than one time its only add once and not repeated. same goes when I insert "efg" ?

Thank you for your concern.
Posted
Updated 10-Sep-13 19:21pm
v2

Handle the changed event and check for duplicates in that event.

This post[^] might help.
 
Share this answer
 
Comments
gogole_yuna 10-Sep-13 23:30pm    
@Abhinav huhu could not really understand. I need to handle the change event and check for duplicates on drop down list ?
While Adding Values In Drop Down List You Can Check for the Item already Exist Or Not using Contains Function.
If Item already exist then don't add this Item In Drop Down List.
See the below code:
VB
If Not ddl.Items.Contains("TestValue") Then
     'Add to Drop Down List
Else
     'Else Do Nothing
End If

I hope it will help you. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900