# ListView\.SelectedIndexCollection

Namespace: **Wisej.Web**

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

Represents the collection that contains the indexes to the selected items in a [ListView](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview) 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

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) SelectedIndexCollection(owner)

Initializes a new instance of the [SelectedIndexCollection](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview/wisej.web.listview.selectedindexcollection) class.

| Name      | Type                                                                      | Description                                                                                                   |
| --------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| **owner** | [ListView](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview) | A [ListView](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview) control that owns the collection. |

## Properties

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) Count

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

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) IsReadOnly

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

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) 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](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview/wisej.web.listview.selectedindexcollection).

## Methods

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) Add(index)

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

| Parameter | Type                                                        | Description                                                                                                                                                                                                                                           |
| --------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **index** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The index of the item in the [Items](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview/..#items) collection to add to the [SelectedIndices](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview/..#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](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview). Or The owner [ListView](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview) is in virtual mode, and the specified index is less than 0 or greater than or equal to the value of [VirtualListSize](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview/..#virtuallistsize).

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) Clear()

Clears the selection.

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) 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](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview/wisej.web.listview.listviewitemcollection) for the [ListView](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview) is an item in the collection; otherwise, false.

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) 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* .                            |

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) 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.

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) IndexOf(selectedIndex)

Returns the index within the [SelectedIndexCollection](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview/wisej.web.listview.selectedindexcollection) of the specified index from the [ListViewItemCollection](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview/wisej.web.listview.listviewitemcollection) 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](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview/wisej.web.listview.listviewitemcollection) 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](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview/wisej.web.listview.listviewitemcollection) is located within the [SelectedIndexCollection](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview/wisej.web.listview.selectedindexcollection); otherwise, -1 if the index is not located in the collection.

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) Remove(index)

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

| Parameter | Type                                                        | Description                                                                                                                                                                                                                                                |
| --------- | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **index** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The index of the item in the [Items](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview/..#items) collection to remove from the [SelectedIndices](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview/..#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](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview). Or The owner [ListView](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview) is in virtual mode, and the specified index is less than 0 or greater than or equal to the value of [VirtualListSize](https://docs.wisej.com/api/wisej.web/lists-and-grids/listview/..#virtuallistsize).
