> For the complete documentation index, see [llms.txt](https://docs.wisej.com/api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wisej.com/api/wisej.web/general/control/wisej.web.control.controlcollection.md).

# Control.ControlCollection

Namespace: **Wisej.Web**

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

Represents a collection of [Control](/api/wisej.web/general/control.md) objects.

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

```csharp
public class ControlCollection : ControlCollection, IList<Control>, ICollection<Control>, IEnumerable<Control>, IWisejSynchronized
```

{% endtab %}

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

```visual-basic
Public Class ControlCollection
    Inherits ControlCollection
    Implements IList(Of Control), ICollection(Of Control), IEnumerable(Of Control), IWisejSynchronized
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](/files/hsR4ok3152WyAf8J2C1u) ControlCollection(owner)

Initializes a new instance of the [ControlCollection](/api/wisej.web/general/control/wisej.web.control.controlcollection.md) class.

| Name      | Type                                         | Description                                                                 |
| --------- | -------------------------------------------- | --------------------------------------------------------------------------- |
| **owner** | [Control](/api/wisej.web/general/control.md) | The [Control](/api/wisej.web/general/control.md) that owns this collection. |

## Properties

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

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns whether the owner control has already been disposed.

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

[Control](/api/wisej.web/general/control.md): Returns the [Control](/api/wisej.web/general/control.md) at the specified indexed location.

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

[Control](/api/wisej.web/general/control.md): Returns the [Control](/api/wisej.web/general/control.md) with the specified key in the collection.

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

[Control](/api/wisej.web/general/control.md): Returns the control that owns this [ControlCollection](/api/wisej.web/general/control/wisej.web.control.controlcollection.md).

## Methods

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

Adds the specified control to the control collection.

| Parameter | Type                                         | Description                                              |
| --------- | -------------------------------------------- | -------------------------------------------------------- |
| **child** | [Control](/api/wisej.web/general/control.md) | The [Control](/api/wisej.web/general/control.md) to add. |

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

Adds an array of control objects to the collection.

| Parameter    | Type                                             | Description                                                                                |
| ------------ | ------------------------------------------------ | ------------------------------------------------------------------------------------------ |
| **controls** | [Control\[\]](/api/wisej.web/general/control.md) | An array of [Control](/api/wisej.web/general/control.md) objects to add to the collection. |

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

Removes all controls from the collection.

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

Removes and disposes all controls from the collection.

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

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

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

| Parameter   | Type                                         | Description                                                                   |
| ----------- | -------------------------------------------- | ----------------------------------------------------------------------------- |
| **control** | [Control](/api/wisej.web/general/control.md) | The [Control](/api/wisej.web/general/control.md) to locate in the collection. |

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean). true if the [Control](/api/wisej.web/general/control.md) is a member of the collection; otherwise, false.

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

Determines whether the [ControlCollection](/api/wisej.web/general/control/wisej.web.control.controlcollection.md) contains an item with the specified key.

| Parameter | Type                                                          | Description                                                                                                          |
| --------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| **key**   | [String](https://docs.microsoft.com/dotnet/api/system.string) | The key to locate in the [ControlCollection](/api/wisej.web/general/control/wisej.web.control.controlcollection.md). |

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean). true if the [ControlCollection](/api/wisej.web/general/control/wisej.web.control.controlcollection.md) contains an item with the specified key; otherwise, false.

### ![](/files/hsR4ok3152WyAf8J2C1u) Find(type, searchAllChildren)

Searches for controls by their type and builds an array of all the controls that match.

| Parameter             | Type                                                            | Description                                                                                                                           |
| --------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| **type**              | [Type](https://docs.microsoft.com/dotnet/api/system.type)       | The type of the controls to locate in the [ControlCollection](/api/wisej.web/general/control/wisej.web.control.controlcollection.md). |
| **searchAllChildren** | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) | true to search all child controls; otherwise, false.                                                                                  |

**Returns:** [Control\[\]](/api/wisej.web/general/control.md). Array of controls that are derived from the specified *type* .

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception) *type* is null.

### ![](/files/hsR4ok3152WyAf8J2C1u) Find(key, searchAllChildren)

Searches for controls by their name and builds an array of all the controls that match.

| Parameter             | Type                                                            | Description                                                                                                           |
| --------------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| **key**               | [String](https://docs.microsoft.com/dotnet/api/system.string)   | The key to located in the [ControlCollection](/api/wisej.web/general/control/wisej.web.control.controlcollection.md). |
| **searchAllChildren** | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) | true to search all child controls; otherwise, false.                                                                  |

**Returns:** [Control\[\]](/api/wisej.web/general/control.md). Array of controls with the specified name.

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception) The *key* parameter is null or an empty string ("").

### ![](/files/hsR4ok3152WyAf8J2C1u) GetChildIndex(child, throwException)

Retrieves the index of the specified child control within the control collection, and optionally raises an exception if the specified control is not within the control collection.

| Parameter          | Type                                                            | Description                                                                                                                                                                                                                                             |
| ------------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **child**          | [Control](/api/wisej.web/general/control.md)                    | The [Control](/api/wisej.web/general/control.md) to search for in the control collection.                                                                                                                                                               |
| **throwException** | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) | true to throw an exception if the [Control](/api/wisej.web/general/control.md) specified in the *child* parameter is not a control in the [ControlCollection](/api/wisej.web/general/control/wisej.web.control.controlcollection.md); otherwise, false. |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). A zero-based index value that represents the location of the specified child control within the control collection; otherwise -1 if the specified [Control](/api/wisej.web/general/control.md) is not found in the [ControlCollection](/api/wisej.web/general/control/wisej.web.control.controlcollection.md).

**Throws:**

* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception) The *child* [Control](/api/wisej.web/general/control.md) is not in the [ControlCollection](/api/wisej.web/general/control/wisej.web.control.controlcollection.md), and the *throwException* parameter value is true.

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

Retrieves a reference to an enumerator object that is used to iterate over a [ControlCollection](/api/wisej.web/general/control/wisej.web.control.controlcollection.md).

**Returns:** [IEnumerator](https://docs.microsoft.com/dotnet/api/system.collections.ienumerator). An [IEnumerator](https://docs.microsoft.com/dotnet/api/system.collections.ienumerator).

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

Retrieves the index of the specified control in the control collection.

| Parameter   | Type                                         | Description                                                                   |
| ----------- | -------------------------------------------- | ----------------------------------------------------------------------------- |
| **control** | [Control](/api/wisej.web/general/control.md) | The [Control](/api/wisej.web/general/control.md) to locate in the collection. |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). A zero-based index value that represents the position of the specified [Control](/api/wisej.web/general/control.md) in the [ControlCollection](/api/wisej.web/general/control/wisej.web.control.controlcollection.md).

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

Retrieves the index of the first occurrence of the specified item within the collection.

| Parameter | Type                                                          | Description                            |
| --------- | ------------------------------------------------------------- | -------------------------------------- |
| **key**   | [String](https://docs.microsoft.com/dotnet/api/system.string) | The name of the control to search for. |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The zero-based index of the first occurrence of the control with the specified name in the collection.

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

Removes the specified control from the control collection.

| Parameter | Type                                         | Description                                                 |
| --------- | -------------------------------------------- | ----------------------------------------------------------- |
| **child** | [Control](/api/wisej.web/general/control.md) | The [Control](/api/wisej.web/general/control.md) to remove. |

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

Removes the child control with the specified key.

| Parameter | Type                                                          | Description                              |
| --------- | ------------------------------------------------------------- | ---------------------------------------- |
| **key**   | [String](https://docs.microsoft.com/dotnet/api/system.string) | The name of the child control to remove. |

### ![](/files/hsR4ok3152WyAf8J2C1u) SetChildIndex(child, newIndex)

Sets the index of the specified child control in the collection.

| Parameter    | Type                                                        | Description                         |
| ------------ | ----------------------------------------------------------- | ----------------------------------- |
| **child**    | [Control](/api/wisej.web/general/control.md)                | The child control to search for.    |
| **newIndex** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The new index value of the control. |

## Inherited By

| Name                                                                                                                 | Description                                                            |
| -------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| [TableLayoutControlCollection](/api/wisej.web/containers/tablelayoutpanel/wisej.web.tablelayoutcontrolcollection.md) | Represents a collection of child controls in a table layout container. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/general/control/wisej.web.control.controlcollection.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.
