Combo Box

Removing items

To add remove an item from a combo box during runtime, you can use the following syntax:

Combo1.RemoveItem Index

where Index is a integer representing the list index of the item to be removed. So if you use the previous example, David would have a list index of 0 (first item) , Paul's would be 1, and Sarah's 2. Note that if the combo is sorted, the list index will change as items are added. The following code removes the selected item, and the first item on the list.

' Remove the first item
Combo1.RemoveItem 0
' Remove the selected item
Combo1.RemoveItem Combo1.listindex

The listindex property returns the listindex of the currently selected item.

To remove all the items from a combo box simply use the following statement:

Combo1.Clear

You might also like...

Comments

About the author

James Crowley

James Crowley United Kingdom

James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“In theory, theory and practice are the same. In practice, they're not.”