Export (0) Print
Expand All

ListView.SelectedIndices Property

Gets the indexes of the selected items in the control.

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

[<BrowsableAttribute(false)>]
member SelectedIndices : ListView..::..SelectedIndexCollection

Property Value

Type: System.Windows.Forms.ListView.SelectedIndexCollection
A ListView.SelectedIndexCollection that contains the indexes of the selected items. If no items are currently selected, an empty ListView.SelectedIndexCollection is returned.

The SelectedIndices property will not contain any indexes if the property is accessed before the ListView handle is created, which typically occurs when the ListView is initially loaded for display in the form. You can check to see if the handle is created with the IsHandleCreated property. When the MultiSelect property is set to true, this property returns a collection containing the indexes of all items that are selected in the ListView. For a single-selection ListView, this property returns a collection containing a single element containing the index of the only selected item in the ListView. For more information on the tasks that can be performed with the items in the collection, see ListView.SelectedIndexCollection.

If you want to obtain a collection of the items that are selected in the ListView control, instead of the index positions of the items that are selected, use the SelectedItems property.

The following code example demonstrates using the SelectedIndices, SelectedIndexChanged, and HeaderStyle members and the ListView.SelectedIndexCollection class. To run this example, paste the following code into a form that contains a ListView object named ListView1 and a TextBox named TextBox1. Call the InitializeListView method from the form's constructor or Load method. This example requires the event handler is correctly associated with the SelectedIndexChanged event.

No code example is currently available or this language may not be supported.

ListView.SelectIndices, SelectedIndexCollection, ListView.SelectedIndexChanged event, 


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.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