How to: Add and Remove Items with the Windows Forms ListView Control

The process of adding an item to a Windows Forms ListView control consists primarily of specifying the item and assigning properties to it. Adding or removing list items can be done at any time.

To add items programmatically

  • Use the Add method of the Items property.

    ' Adds a new item with ImageIndex 3
    ListView1.Items.Add("List item text", 3)
    
    // Adds a new item with ImageIndex 3
    listView1.Items.Add("List item text", 3);
    

To remove items programmatically

  • Use the RemoveAt or Clear method of the Items property. The RemoveAt method removes a single item; the Clear method removes all items from the list.

    ' Removes the first item in the list.
    ListView1.Items.RemoveAt(0)
    ' Clears all items:
    ListView1.Items.Clear()
    
    // Removes the first item in the list.
    listView1.Items.RemoveAt(0);
    // Clears all the items.
    listView1.Items.Clear();
    

See Also

Reference

ListView Control Overview (Windows Forms)

ListView

Other Resources

ListView Control (Windows Forms)