# ListView\.SelectedIndexCollection

Namespace: **Wisej.Web**

Assembly: **Wisej.Framework** (3.2.0.0)

Represents the collection that contains the indexes to the selected items in a [ListView](/api/v3.2/wisej.web/lists-and-grids/listview.md) control.

{% tabs %}
{% tab title="C#" %}

```csharp
public class SelectedIndexCollection : IList<Int32>, ICollection<Int32>, IEnumerable<Int32>, IEnumerable, IList, ICollection
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class SelectedIndexCollection
    Inherits IList(Of Int32)
    Implements ICollection(Of Int32), IEnumerable(Of Int32), IEnumerable, IList, ICollection
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](/files/k9JaCemfGSiwecs59re6)SelectedIndexCollection(owner)

Initializes a new instance of the [SelectedIndexCollection](/api/v3.2/wisej.web/lists-and-grids/listview/wisej.web.listview.selectedindexcollection.md) class.

| Name      | Type                                                        | Description                                                                                     |
| --------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| **owner** | [ListView](/api/v3.2/wisej.web/lists-and-grids/listview.md) | A [ListView](/api/v3.2/wisej.web/lists-and-grids/listview.md) control that owns the collection. |

## Properties

### ![](/files/k9JaCemfGSiwecs59re6)Count

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Returns the number of items in the collection.

### ![](/files/k9JaCemfGSiwecs59re6)IsReadOnly

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns whether the collection is read-only.

### ![](/files/k9JaCemfGSiwecs59re6)Item(index)

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Returns the index value at the specified index within the collection.

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception) The *index* parameter is less than 0 or greater than or equal to the value of the [Count](#count) property of [SelectedIndexCollection](/api/v3.2/wisej.web/lists-and-grids/listview/wisej.web.listview.selectedindexcollection.md).

## Methods

### ![](/files/k9JaCemfGSiwecs59re6)Add(index)

Adds the item at the specified index in the [Items](/api/v3.2/wisej.web/lists-and-grids/listview.md#items) collection to the [SelectedIndices](/api/v3.2/wisej.web/lists-and-grids/listview.md#selectedindices) collection.

| Parameter | Type                                                        | Description                                                                                                                                                                                                         |
| --------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **index** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The index of the item in the [Items](/api/v3.2/wisej.web/lists-and-grids/listview.md#items) collection to add to the [SelectedIndices](/api/v3.2/wisej.web/lists-and-grids/listview.md#selectedindices) collection. |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The new count of selected items.

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception) The specified index is less than 0 or greater than or equal to the number of items in the owner [ListView](/api/v3.2/wisej.web/lists-and-grids/listview.md). Or The owner [ListView](/api/v3.2/wisej.web/lists-and-grids/listview.md) is in virtual mode, and the specified index is less than 0 or greater than or equal to the value of [VirtualListSize](/api/v3.2/wisej.web/lists-and-grids/listview.md#virtuallistsize).

### ![](/files/k9JaCemfGSiwecs59re6)Clear()

Clears the selection.

### ![](/files/k9JaCemfGSiwecs59re6)Contains(selectedIndex)

Determines whether the specified index is located in the collection.

| Parameter         | Type                                                        | Description                                                 |
| ----------------- | ----------------------------------------------------------- | ----------------------------------------------------------- |
| **selectedIndex** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The index of the selected item to locate in the collection. |

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean). true if the specified index from the [ListViewItemCollection](/api/v3.2/wisej.web/lists-and-grids/listview/wisej.web.listview.listviewitemcollection.md) for the [ListView](/api/v3.2/wisej.web/lists-and-grids/listview.md) is an item in the collection; otherwise, false.

### ![](/files/k9JaCemfGSiwecs59re6)CopyTo(array, index)

Copies the list of selected indexes into the specified *array* starting at the specified *index* .

| Parameter | Type                                                            | Description                                            |
| --------- | --------------------------------------------------------------- | ------------------------------------------------------ |
| **array** | [Int32\[\]](https://docs.microsoft.com/dotnet/api/system.int32) | Array that will received the list of selected indexes. |
| **index** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32)     | Starting index in *array* .                            |

### ![](/files/k9JaCemfGSiwecs59re6)GetEnumerator()

Returns an enumerator that can be used to iterate through the selected index collection.

**Returns:** [IEnumerator\<Int32>](https://docs.microsoft.com/dotnet/api/system.collections.generic.ienumerator-1). An [IEnumerator](https://docs.microsoft.com/dotnet/api/system.collections.ienumerator) that represents the selected index collection.

### ![](/files/k9JaCemfGSiwecs59re6)IndexOf(selectedIndex)

Returns the index within the [SelectedIndexCollection](/api/v3.2/wisej.web/lists-and-grids/listview/wisej.web.listview.selectedindexcollection.md) of the specified index from the [ListViewItemCollection](/api/v3.2/wisej.web/lists-and-grids/listview/wisej.web.listview.listviewitemcollection.md) of the list view control.

| Parameter         | Type                                                        | Description                                                                                                                                                                    |
| ----------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **selectedIndex** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The zero-based index from the [ListViewItemCollection](/api/v3.2/wisej.web/lists-and-grids/listview/wisej.web.listview.listviewitemcollection.md) to locate in the collection. |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The zero-based index in the collection where the specified index of the [ListViewItemCollection](/api/v3.2/wisej.web/lists-and-grids/listview/wisej.web.listview.listviewitemcollection.md) is located within the [SelectedIndexCollection](/api/v3.2/wisej.web/lists-and-grids/listview/wisej.web.listview.selectedindexcollection.md); otherwise, -1 if the index is not located in the collection.

### ![](/files/k9JaCemfGSiwecs59re6)Remove(index)

Removes the item at the specified index in the [Items](/api/v3.2/wisej.web/lists-and-grids/listview.md#items) collection from the [SelectedIndices](/api/v3.2/wisej.web/lists-and-grids/listview.md#selectedindices) collection.

| Parameter | Type                                                        | Description                                                                                                                                                                                                              |
| --------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **index** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The index of the item in the [Items](/api/v3.2/wisej.web/lists-and-grids/listview.md#items) collection to remove from the [SelectedIndices](/api/v3.2/wisej.web/lists-and-grids/listview.md#selectedindices) collection. |

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception) The specified index is less than 0 or greater than or equal to the number of items in the owner [ListView](/api/v3.2/wisej.web/lists-and-grids/listview.md). Or The owner [ListView](/api/v3.2/wisej.web/lists-and-grids/listview.md) is in virtual mode, and the specified index is less than 0 or greater than or equal to the value of [VirtualListSize](/api/v3.2/wisej.web/lists-and-grids/listview.md#virtuallistsize).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/api/v3.2/wisej.web/lists-and-grids/listview/wisej.web.listview.selectedindexcollection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
