# ComponentToolCollection

Namespace: **Wisej.Web**

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

Represents a set of tool widgets associated with a component. The component includes the tools panel according to its design. For example, the [Form](/api/wisej.web/containers/form.md) component includes the tools in its caption bar. Other components may include the tools elsewhere.

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

```csharp
public class ComponentToolCollection : IList, ICollection, IEnumerable, IList<ComponentTool>, ICollection<ComponentTool>, IEnumerable<ComponentTool>
```

{% endtab %}

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

```visual-basic
Public Class ComponentToolCollection
    Inherits IList
    Implements ICollection, IEnumerable, IList(Of ComponentTool), ICollection(Of ComponentTool), IEnumerable(Of ComponentTool)
```

{% endtab %}
{% endtabs %}

## Constructors

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

Initializes a new instance of the [ComponentToolCollection](/api/wisej.web/editors/wisej.web.componenttoolcollection.md) class not bound to any control.

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

Initializes a new instance of the [ComponentToolCollection](/api/wisej.web/editors/wisej.web.componenttoolcollection.md) class.

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

## Properties

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

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

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

[ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md): Returns or sets the [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) at the specified index.

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

[ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md): Returns the [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) identified by the name.

## Methods

### ![](/files/hsR4ok3152WyAf8J2C1u) Add(name, imageSource)

Adds a [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) with the specified name and image source to the collection.

| Parameter       | Type                                                          | Description                                                                                              |
| --------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| **name**        | [String](https://docs.microsoft.com/dotnet/api/system.string) | The name of the [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) that is being added.  |
| **imageSource** | [String](https://docs.microsoft.com/dotnet/api/system.string) | The image of the [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) that is being added. |

**Returns:** [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md). A [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) that represents the panel that was added to the collection.

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

Adds a [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) to the collection.

| Parameter | Type                                                               | Description                                                                                                              |
| --------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ |
| **tool**  | [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) | A [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) that represents the panel to add to the collection. |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  The [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) being added to the collection was null.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  The parent of the [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) specified in the *tool* parameter is not null.

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

Adds an array of [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) to the collection

| Parameter | Type                                                                   | Description |
| --------- | ---------------------------------------------------------------------- | ----------- |
| **tools** | [ComponentTool\[\]](/api/wisej.web/editors/wisej.web.componenttool.md) |             |

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

Removes all tools from the collection.

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

Removes and optionally disposes all tools from the collection.

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

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

Determines whether the specified panel is located within the collection.

| Parameter | Type                                                               | Description                                                                                         |
| --------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------- |
| **tool**  | [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) | The [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) to locate in the collection. |

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean). true if the panel is located within the collection; otherwise, false.

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

Determines whether the collection contains a [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) with the specified key.

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

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean). true to indicate the collection contains a [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) with the specified key; otherwise, false.

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

Returns an enumerator to use to iterate through the item collection.

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

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

Returns the index within the collection of the specified panel.

| Parameter | Type                                                               | Description                                                                                         |
| --------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------- |
| **tool**  | [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) | The [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) to locate in the collection. |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The zero-based index where the panel is located within the collection; otherwise, negative one (-1).

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

Returns the index of the first occurrence of a [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) with the specified key.

| Parameter | Type                                                          | Description                                                                                                   |
| --------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| **key**   | [String](https://docs.microsoft.com/dotnet/api/system.string) | The name of the [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) to find in the collection. |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The zero-based index of the first occurrence of the [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) with the specified key, if found; otherwise, -1.

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

Inserts the specified [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) into the collection at the specified index.

| Parameter | Type                                                               | Description                                                                                            |
| --------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
| **index** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32)        | The zero-based index location where the panel is inserted.                                             |
| **tool**  | [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) | A [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) representing the panel to insert. |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  The *tool* parameter is null.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  The *tool* parameter's parent is not null.
* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)\
  The *index* parameter is less than zero or greater than the value of the [Count](#count) property of the [ComponentToolCollection](/api/wisej.web/editors/wisej.web.componenttoolcollection.md) class.

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

Removes the specified [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) from the collection.

| Parameter | Type                                                               | Description                                                                                                                  |
| --------- | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
| **tool**  | [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) | The [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) representing the panel to remove from the collection. |

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean).

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  The [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) assigned to the *tool* parameter is null.

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

Removes the [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) located at the specified index within the collection.

| Parameter | Type                                                        | Description                                 |
| --------- | ----------------------------------------------------------- | ------------------------------------------- |
| **index** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The zero-based index of the item to remove. |

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)\
  The *index* parameter is less than zero or greater than or equal to the value of the [Count](#count) property of the [ComponentToolCollection](/api/wisej.web/editors/wisej.web.componenttoolcollection.md) class.

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

Removes the [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) with the specified key from the collection.

| Parameter | Type                                                          | Description                                                                                                       |
| --------- | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| **key**   | [String](https://docs.microsoft.com/dotnet/api/system.string) | The name of the [ComponentTool](/api/wisej.web/editors/wisej.web.componenttool.md) to remove from the collection. |


---

# 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/editors/wisej.web.componenttoolcollection.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.
