This article demonstrate how to add, remove and clear items from listbox in vb.net
Add items to Listbox
- ListBox1.Items.Add("NewDelhi")
Add items to Listbox from array
You can add an array of items to the list of items for a System.Windows.Forms.ListBox with the help of AddRange() method.
- Dim strArr() As String = {"NewDelhi", "Londan", "Kolkata", "Sydney", "NewYork"}
- ListBox1.Items.AddRange(strArr)
Remove item from Listbox
- ListBox1.Items.Remove("Londan")
You can remove the item at the specified index within the collection with the help of RemoveAt() method.
- ListBox1.Items.RemoveAt(2)
Clear items in Listbox
you can removes all items from the item collection.
- ListBox1.Items.Clear()