Not sure what I am doing wrong but let me try to explain my issue. I have a single combobox on my form that I use to load external settings. If I load, lets say, 100 settings in to this combobox then I clear the combobox via Combobox1.items.clear(), then try to reload a different set of settings that has a far less overall count, the combobox will not load the items and the dropdownlist will be massive but blank.

NOW, if I load the settings that have far less then clear and load the settings with significantly more settings, then it loads just fine.

My combobox is set to dropdownlist and so far I have tried this:

Combobox1.items.clear()
Combobox1.Refresh()
Combobox1.SelectedIndex = -1

By themselves and used in conjuntion with one another. Nothing I have tried has resolved this. Anyone else had this issue or know what is causing this issue so I can properly fix it?

When I run the following code

Private Sub Button_Click(sender As System.Object, e As System.EventArgs) Handles btnCol1.Click
    For i = 1 To 100
        ComboBox1.Items.Add(i)
    Next
End Sub

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    ComboBox1.Items.Clear()
    For i = 1001 To 1010
        ComboBox1.Items.Add(i)
    Next
End Sub

I get what I would expect. After btnCol1.Click I get a combobox with items 1-100. After Button1.Click I get a combobox with items 1001-1010. No large but mostly empty list. Everything looks fine. Try doing a Debug.WriteLine when you are adding the items and see if you notice anything unusual.

Just figured out why after I took a day off from the project. I was loading everything in to a dictionary first, then loading it in to a combobox. The dictionary was in a key:value format so I can save their settings without having to write to disk everytime they changed a setting. I simply had to reset the dictionary too... lol, sorry folks :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.