Quantcast
Viewing all articles
Browse latest Browse all 9

Add, remove And clear items in List Box in vb.net

 
This article demonstrate how to add, remove and clear items from listbox in vb.net

Add items to Listbox

  1. 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.

  1. Dim strArr() As String = {"NewDelhi", "Londan", "Kolkata", "Sydney", "NewYork"}
  2. ListBox1.Items.AddRange(strArr)

Remove item from Listbox

  1. ListBox1.Items.Remove("Londan")

You can remove the item at the specified index within the collection with the help of RemoveAt() method.

  1. ListBox1.Items.RemoveAt(2)

Clear items in Listbox
you can removes all items from the item collection.

  1. ListBox1.Items.Clear()

Viewing all articles
Browse latest Browse all 9

Trending Articles