Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

ComboBox - Item Add

$
0
0
Hi,

Hope you can help. I'm using a combobox for my user to chose an option from which then loads text / items into another combobox.

The problem I'm having is that if I keep flicking between comboboxes it keeps adding the items over and over again. I know that's doing it because the code is telling it to do it but is there anyway to add any validation to say if items have already been added don't add them again?

I don't really want to change the code as its the way I want to program to work.

Code i'm using to get a basic idea:

Code:

Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
        If ComboBox1.Text = "Colour" Then
              ComboBox2.Items.Add("Blue")
              ComboBox2.Items.Add("Yellow")
              ComboBox2.Items.Add("Green")
        End If
    End Sub

Thanks
Ian

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>