Export (0) Print
Expand All

ListView.SelectedIndexCollection.Add Method

Adds the item at the specified index in the Items array to the collection.

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

public int Add(
	int itemIndex
)

Parameters

itemIndex
Type: System.Int32
The index of the item in the Items collection to be added to the ListView.SelectedIndexCollection.

Return Value

Type: System.Int32
The number of items in the ListView.SelectedIndexCollection.

ExceptionCondition
ArgumentOutOfRangeException

The specified index is less than 0 or greater than or equal to the number of items in the owner ListView.

-or-

The owner ListView is in virtual mode, and the specified index is less than 0 or greater than or equal to the value of VirtualListSize.

This method will return 0 if the handle has not been created for the owning ListView. (You can determine whether the ListView has an associated handle by using the Control.IsHandleCreated property.) This method will return -1 if the handle has not been created for a virtual ListView.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Community Additions

ADD
Show:
© 2014 Microsoft