Export (0) Print
Expand All

ListView.ListViewItemCollection Class

Represents the collection of items in a ListView control.

For a list of all members of this type, see ListView.ListViewItemCollection Members.

System.Object
   System.Windows.Forms.ListView.ListViewItemCollection

[Visual Basic]
Public Class ListView.ListViewItemCollection
   Implements IList, ICollection, IEnumerable
[C#]
public class ListView.ListViewItemCollection : IList, ICollection,
   IEnumerable
[C++]
public __gc class ListView.ListViewItemCollection : public IList,
   ICollection, IEnumerable
[JScript]
public class ListView.ListViewItemCollection implements IList,
   ICollection, IEnumerable

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

A ListView.ListViewItemCollection stores the items displayed in the ListView control. There are two other collections defined within the ListView class that enable you to determine what items are selected within this collection. The ListView.SelectedListViewItemCollection class provides properties and methods for determining what items are selected in the ListView.ListViewItemCollection, while the ListView.SelectedIndexCollection class enables you to determine what indexes within the ListView.ListViewItemCollection are selected. In addition to selection collection classes there are also two classes that enable you to determine what items are checked (when the CheckBoxes property of the ListView control is set to true) within this collection.

There are a number of ways to add items to the collection. The Add method adds a single item to the collection. To add a number of items to the collection, you create an array of items and pass it to the AddRange method. If you want to insert an item at a specific location in the collection, you can use the Insert method. To remove items, you can use either the Remove method or the RemoveAt method if you know where the item is located in the collection. The Clear method enables you to remove all items from the collection instead of using the Remove method to remove a single item at a time.

In addition to methods and properties for adding and removing items, the ListView.ListViewItemCollection also provides methods to find items in the collection. The Contains method enables you to determine whether an item is a member of the collection. Once you know that the item is located in the collection, you can use the IndexOf method to determine where the item is located in the collection.

Requirements

Namespace: System.Windows.Forms

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: System.Windows.Forms (in System.Windows.Forms.dll)

See Also

ListView.ListViewItemCollection Members | System.Windows.Forms Namespace | ListView.SelectedListViewItemCollection | ListView.SelectedIndexCollection

Show:
© 2014 Microsoft