# ListViewItem.ListViewSubItemCollection

Namespace: **Wisej.Web**

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

Represents the collection of subitems in a [ListViewSubItem](/api/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.listviewsubitem.md) item.

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

```csharp
public class ListViewSubItemCollection : IList, ICollection, IEnumerable, IList<ListViewSubItem>, ICollection<ListViewSubItem>, IEnumerable<ListViewSubItem>
```

{% endtab %}

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

```visual-basic
Public Class ListViewSubItemCollection
    Inherits IList
    Implements ICollection, IEnumerable, IList(Of ListViewSubItem), ICollection(Of ListViewSubItem), IEnumerable(Of ListViewSubItem)
```

{% endtab %}
{% endtabs %}

## Properties

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

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

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

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

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

[ListViewSubItem](/api/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.listviewsubitem.md): Returns or sets the subitem at the specified index in the collection.

**Throws:**

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

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

[ListViewSubItem](/api/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.listviewsubitem.md): Returns the subitem with the specified key from the collection.

## Methods

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

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

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

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

### ![](/files/hsR4ok3152WyAf8J2C1u) Add(text, foreColor, backColor, font)

Adds a new subitem to the collection with the specified text, foreground color, background color, and font settings.

| Parameter     | Type                                                                | Description                                                                                                                        |
| ------------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| **text**      | [String](https://docs.microsoft.com/dotnet/api/system.string)       | The text to display for the subitem.                                                                                               |
| **foreColor** | [Color](https://docs.microsoft.com/dotnet/api/system.drawing.color) | A [Color](https://docs.microsoft.com/dotnet/api/system.drawing.color) that represents the foreground color of the subitem.         |
| **backColor** | [Color](https://docs.microsoft.com/dotnet/api/system.drawing.color) | A [Color](https://docs.microsoft.com/dotnet/api/system.drawing.color) that represents the background color of the subitem.         |
| **font**      | [Font](https://docs.microsoft.com/dotnet/api/system.drawing.font)   | A [Font](https://docs.microsoft.com/dotnet/api/system.drawing.font) that represents the typeface to display the subitem's text in. |

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

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

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

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

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

**Throws:**

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

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

Creates new subitems based on an array of strings and adds them to the collection.

| Parameter | Type                                                              | Description                                                                         |
| --------- | ----------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| **items** | [String\[\]](https://docs.microsoft.com/dotnet/api/system.string) | An array of strings representing the text of each subitem to add to the collection. |

### ![](/files/hsR4ok3152WyAf8J2C1u) AddRange(items, foreColor, backColor, font)

Creates new subitems based on an array of strings and adds them to the collection with the specified foreground color, background color, and font.

| Parameter     | Type                                                                | Description                                                                                                                        |
| ------------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| **items**     | [String\[\]](https://docs.microsoft.com/dotnet/api/system.string)   | An array of strings representing the text of each subitem to add to the collection.                                                |
| **foreColor** | [Color](https://docs.microsoft.com/dotnet/api/system.drawing.color) | A [Color](https://docs.microsoft.com/dotnet/api/system.drawing.color) that represents the foreground color of the subitem.         |
| **backColor** | [Color](https://docs.microsoft.com/dotnet/api/system.drawing.color) | A [Color](https://docs.microsoft.com/dotnet/api/system.drawing.color) that represents the background color of the subitem.         |
| **font**      | [Font](https://docs.microsoft.com/dotnet/api/system.drawing.font)   | A [Font](https://docs.microsoft.com/dotnet/api/system.drawing.font) that represents the typeface to display the subitem's text in. |

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

Adds an array of previously created subitems to the collection.

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

**Throws:**

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

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

Removes all [ListViewSubItem](/api/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.listviewsubitem.md) instances from the collection.

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

Removes all [ListViewSubItem](/api/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.listviewsubitem.md) instances from the collection and optionally disposes them.

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

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

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

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

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

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

Determines whether the collection contains a subitem with the specified key.

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

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

### ![](/files/hsR4ok3152WyAf8J2C1u) 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/dotnet/api/system.array) | The destination array.                                      |
| **index** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The index in the destination array at which storing begins. |

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

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

**Returns:** [IEnumerator\<ListViewSubItem>](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 [ListViewSubItemCollection](/api/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.listviewsubitemcollection.md).

### ![](/files/hsR4ok3152WyAf8J2C1u) IndexOf(subitem)

Returns the index of the specified subitem in the collection.

| Parameter   | Type                                                                                                 | Description                                                                                                                           |
| ----------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| **subitem** | [ListViewSubItem](/api/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.listviewsubitem.md) | The [ListViewSubItem](/api/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.listviewsubitem.md) to locate in the collection. |

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

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

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

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

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

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

Inserts an existing [ListViewSubItem](/api/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.listviewsubitem.md) into the collection at the specified location.

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

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

**Throws:**

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

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

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

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

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

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

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

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

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

### ![](/files/lzopMboA31bVq8UIcbT3) OnCollectionChanged(action, element)

Fires the [CollectionChanged](#collectionchanged) event.

| Parameter   | Type                                                                                                         | Description                                                                                                                                                           |
| ----------- | ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **action**  | [CollectionChangeAction](https://docs.microsoft.com/dotnet/api/system.componentmodel.collectionchangeaction) | One of [CollectionChangeAction](https://docs.microsoft.com/dotnet/api/system.componentmodel.collectionchangeaction) indicating the reason the collection has changed. |
| **element** | [Object](https://docs.microsoft.com/dotnet/api/system.object)                                                | The element that was added or removed from the collection, or null.                                                                                                   |

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

Removes the specified subitem from the collection.

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

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

Removes a subitem from the collection at a specified index.

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

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

Removes the subitem with the specified key from the collection.

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

## Events

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

[CollectionChangeEventHandler](https://docs.microsoft.com/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/wisej.web/lists-and-grids/listview/wisej.web.listviewitem.listviewsubitemcollection.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.
