Export (0) Print
Expand All

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);

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.
            // Clears all the items.
© 2015 Microsoft