Represents the collection of items in a ListView control.
For a list of all members of this type, see ListView.ListViewItemCollection Members.
[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
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
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.
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)