Export (0) Print
Expand All

ListView.ListViewItemCollection.Add Method (String)

Creates an item with the specified text and adds it to the collection.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public virtual ListViewItem Add (
	string text
)
public ListViewItem Add (
	String text
)
public function Add (
	text : String
) : ListViewItem
Not applicable.

Parameters

text

The text to display for the item.

Return Value

The ListViewItem that was added to the collection.

You can use this version of the Add method to create a new ListViewItem to add to a ListView control. The text of the new ListViewItem added to the control is based on the text parameter. If you want to specify an image for the item, use the version of the Add method that accepts an image index as a parameter. If you have an existing ListViewItem that you want to add to the collection, use the version of the Add method that accepts a ListViewItem as its parameter.

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.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft