# ListView\.ListViewItemCollection

Namespace: **Wisej.Web**

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

Represents the collection of items in a [ListView](/api/v3.1/wisej.web/lists-and-grids/listview.md) control.

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

```csharp
public class ListViewItemCollection : IList, ICollection, IEnumerable, IList<ListViewItem>, ICollection<ListViewItem>, IEnumerable<ListViewItem>
```

{% endtab %}

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

```visual-basic
Public Class ListViewItemCollection
    Inherits IList
    Implements ICollection, IEnumerable, IList(Of ListViewItem), ICollection(Of ListViewItem), IEnumerable(Of ListViewItem)
```

{% endtab %}
{% endtabs %}

## Properties

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

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

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

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

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

[ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md): Returns or sets the item at the specified index in the collection.

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception) The *index* value is less than 0 or is greater than the number of items in the collection.

### ![](/files/QmRDluociuQ34KzBtOjf)Item(key)

[ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md): Returns the item with the specified key from the collection.

## Methods

### ![](/files/QmRDluociuQ34KzBtOjf)Add(text)

Adds a new item with the specified label text to the end of the current collection.

| Parameter | Type                                                                | Description                                                                                                             |
| --------- | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| **text**  | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The label text displayed by the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md). |

**Returns:** [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md). A [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) that represents the item being added to the collection.

### ![](/files/QmRDluociuQ34KzBtOjf)Add(key, text)

Creates a new item with the specified key and text, and adds it to the collection.

| Parameter | Type                                                                | Description                                                                                                        |
| --------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| **key**   | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The name of the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md).            |
| **text**  | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The text to display in the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md). |

**Returns:** [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md). The [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) that was added to the collection.

### ![](/files/QmRDluociuQ34KzBtOjf)Add(key, text, imageIndex)

Creates a new item with the specified key, text, and image, and adds it to the collection.

| Parameter      | Type                                                                | Description                                                                                                                      |
| -------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| **key**        | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The name of the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md).                          |
| **text**       | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The text to display in the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md).               |
| **imageIndex** | [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)   | The index of the image to display in the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md). |

**Returns:** [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md). The [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) that was added to the collection.

### ![](/files/QmRDluociuQ34KzBtOjf)Add(key, text, imageKey)

Creates a new item with the specified key, text, and image, and adds it to the collection.

| Parameter    | Type                                                                | Description                                                                                                         |
| ------------ | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| **key**      | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The name of the item.                                                                                               |
| **text**     | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The text to display in the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md).  |
| **imageKey** | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The image to display in the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md). |

**Returns:** [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md). The [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) that was added to the collection.

### ![](/files/QmRDluociuQ34KzBtOjf)Add(item)

Adds a previously created item to the end of the collection.

| Parameter | Type                                                                                   | Description                                                                                                          |
| --------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| **item**  | [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) | The [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) to add to the collection. |

**Returns:** [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32). The zero-based index value of the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) added to the collection.

**Throws:**

* [ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception) The *item* is currently assigned to another [ListView](/api/v3.1/wisej.web/lists-and-grids/listview.md).

### ![](/files/QmRDluociuQ34KzBtOjf)AddRange(items)

Adds an array of previously created items to the collection.

| Parameter | Type                                                                                       | Description                                                                                                                                                 |
| --------- | ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **items** | [ListViewItem\[\]](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) | An array of [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) objects representing the items to add to the collection. |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentnullexception) *items* is null.
* [ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception) *items* is the child of another [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md).

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

Removes all items from the collection.

### ![](/files/QmRDluociuQ34KzBtOjf)Clear(dispose)

Removes all items from the collection and optionally disposes them.

| Parameter   | Type                                                                  | Description                                             |
| ----------- | --------------------------------------------------------------------- | ------------------------------------------------------- |
| **dispose** | [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean) | Indicates whether the removed items should be disposed. |

### ![](/files/QmRDluociuQ34KzBtOjf)Contains(item)

Determines whether the specified item is a member of the collection.

| Parameter | Type                                                                                   | Description                                                                                                             |
| --------- | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| **item**  | [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) | The [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) to locate in the collection. |

**Returns:** [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean). true if the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) is a member of the collection; otherwise, false.

### ![](/files/QmRDluociuQ34KzBtOjf)ContainsKey(key)

Determines whether the collection contains an item with the specified key.

| Parameter | Type                                                                | Description                                                                                                           |
| --------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| **key**   | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The name of the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) to search for. |

**Returns:** [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean). true to indicate the collection contains a [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) with the specified key; otherwise, false.

### ![](/files/QmRDluociuQ34KzBtOjf)CopyTo(dest, index)

Copies the entire collection into an existing array at a specified location within the array.

| Parameter | Type                                                              | Description                                                 |
| --------- | ----------------------------------------------------------------- | ----------------------------------------------------------- |
| **dest**  | [Array](https://docs.microsoft.com/en-us/dotnet/api/system.array) | The destination array.                                      |
| **index** | [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32) | The index in the destination array at which storing begins. |

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

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

**Returns:** [IEnumerator\<ListViewItem>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerator). An [IEnumerator](https://docs.microsoft.com/en-us/dotnet/api/system.collections.ienumerator) that represents the [ListViewItemCollection](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listview.listviewitemcollection.md).

### ![](/files/QmRDluociuQ34KzBtOjf)IndexOf(item)

Returns the index of the specified item in the collection.

| Parameter | Type                                                                                   | Description                                                                                                             |
| --------- | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| **item**  | [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) | The [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) to locate in the collection. |

**Returns:** [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32). The zero-based index of the item found in the [ListViewItemCollection](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listview.listviewitemcollection.md); otherwise, -1.

### ![](/files/QmRDluociuQ34KzBtOjf)IndexOfKey(key)

Returns the index of the first occurrence of a item with the specified key.

| Parameter | Type                                                                | Description                                                                                                           |
| --------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| **key**   | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The name of the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) to search for. |

**Returns:** [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32). The zero-based index of the first occurrence of a [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) with the specified key, if found; otherwise, -1.

### ![](/files/QmRDluociuQ34KzBtOjf)Insert(index, item)

Inserts an existing item into the collection at the specified location.

| Parameter | Type                                                                                   | Description                                                                                                                                            |
| --------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **index** | [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)                      | The indexed location within the collection to insert the item.                                                                                         |
| **item**  | [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) | The [ListViewItemCollection](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listview.listviewitemcollection.md) to insert into the collection. |

**Throws:**

* [ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception) The *item* is currently assigned to another [ListView](/api/v3.1/wisej.web/lists-and-grids/listview.md).

### ![](/files/QmRDluociuQ34KzBtOjf)Insert(index, text)

Creates a new item with the specified text and inserts it at the specified index.

| Parameter | Type                                                                | Description                                                                                                                              |
| --------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| **index** | [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)   | The location within the collection to insert the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md). |
| **text**  | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The text to display in the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md).                       |

**Returns:** [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md). The [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) that was inserted in the collection.

### ![](/files/QmRDluociuQ34KzBtOjf)Insert(index, key, text)

Creates a new item with the specified text and key, and inserts it into the collection.

| Parameter | Type                                                                | Description                                                                                                                              |
| --------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| **index** | [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)   | The location within the collection to insert the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md). |
| **key**   | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The name of the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md).                                  |
| **text**  | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The text to display in the[ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md).                        |

**Returns:** [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md). The [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) that was inserted in the collection.

### ![](/files/QmRDluociuQ34KzBtOjf)Insert(index, key, text, imageIndex)

Creates a new item with the specified key, text, and image, and inserts it into the collection at the specified index.

| Parameter      | Type                                                                | Description                                                                                                                              |
| -------------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| **index**      | [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)   | The location within the collection to insert the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md). |
| **key**        | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The name of the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md).                                  |
| **text**       | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The text to display in the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md).                       |
| **imageIndex** | [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)   | The index of the image to display in the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md).         |

**Returns:** [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md). The [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) that was inserted in the collection.

### ![](/files/QmRDluociuQ34KzBtOjf)Insert(index, key, text, imageKey)

Creates a new item with the specified key, text, and image, and inserts it into the collection at the specified index.

| Parameter    | Type                                                                | Description                                                                                                                              |
| ------------ | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| **index**    | [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)   | The location within the collection to insert the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md). |
| **key**      | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The name of the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md).                                  |
| **text**     | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The text to display in the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md).                       |
| **imageKey** | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The key of the image to display in the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md).           |

**Returns:** [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md). The [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) that was inserted in the collection.

### ![](/files/QmRDluociuQ34KzBtOjf)Remove(item)

Removes the specified item from the collection.

| Parameter | Type                                                                                   | Description                                                                                           |
| --------- | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| **item**  | [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) | The [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) to remove. |

### ![](/files/QmRDluociuQ34KzBtOjf)RemoveAt(index)

Removes the item from the collection at a specified index.

| Parameter | Type                                                              | Description                                                                                                        |
| --------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| **index** | [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32) | The index of the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) to remove. |

### ![](/files/QmRDluociuQ34KzBtOjf)RemoveByKey(key)

Removes the item with the specified key from the collection.

| Parameter | Type                                                                | Description                                                                                                                           |
| --------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| **key**   | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The name of the [ListViewItem](/api/v3.1/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.md) to remove from the collection. |

## Events

### ![](/files/QmRDluociuQ34KzBtOjf)CollectionChanged

[CollectionChangeEventHandler](https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.collectionchangeeventhandler) Fired when the collection changes.


---

# 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.1/wisej.web/lists-and-grids/listview/wisej.web.listview.listviewitemcollection.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.
