Export (0) Print
Expand All

ListView.ListViewItemCollection.Add Method (ListViewItem)

Adds an existing ListViewItem to the collection.

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

public virtual ListViewItem Add(
	ListViewItem value
)

Parameters

value
Type: System.Windows.Forms.ListViewItem

The ListViewItem to add to the collection.

Return Value

Type: System.Windows.Forms.ListViewItem
The ListViewItem that was added to the collection.

You can use this version of the Add method to add an existing ListViewItem to the collection. This version of the Add method is typically used to reuse items from other ListView controls or if the ListViewItem was created manually before adding it to the collection. If you want to create a new ListViewItem instead of using an existing item, use the other versions of the Add method.

If the ListView.Sorting property is set to a value other than SortOrder.None or if the ListViewItemSorter property is set, the list is sorted after the item is added. Otherwise, the item is inserted at the end of the list. If the list is not sorted, you can use the Insert method to insert an item into the ListView at a specific position. To add a set of items to the control in a single operation, use the AddRange method. If you want to use the Add method to add a large number of items to the control, use the BeginUpdate and EndUpdate methods to prevent the ListView from repainting until all items are added. When adding items to a ListView, it is more efficient to sort the items first and then add new items.

This version of the Add method is also used to assign a ListViewItem to a ListViewGroup.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft