# ToolBar.ToolBarButtonCollection

Namespace: **Wisej.Web**

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

Represents the collection of [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) controls in a [ToolBar](https://docs.wisej.com/api/wisej.web/containers/toolbar) control.

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

```csharp
public class ToolBarButtonCollection : IList, ICollection, IEnumerable, IList<ToolBarButton>, ICollection<ToolBarButton>, IEnumerable<ToolBarButton>
```

{% endtab %}

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

```visual-basic
Public Class ToolBarButtonCollection
    Inherits IList
    Implements ICollection, IEnumerable, IList(Of ToolBarButton), ICollection(Of ToolBarButton), IEnumerable(Of ToolBarButton)
```

{% 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) ToolBarButtonCollection(owner)

Initializes a new instance of the [ToolBarButtonCollection](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbar.toolbarbuttoncollection) class.

| Name      | Type                                                               | Description                                                                                               |
| --------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------- |
| **owner** | [ToolBar](https://docs.wisej.com/api/wisej.web/containers/toolbar) | The [ToolBar](https://docs.wisej.com/api/wisej.web/containers/toolbar) control that owns this 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) IsReadOnly

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns a value indicating whether this 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)

[ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton): Returns or sets the [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) at the specified index.

### ![](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(name)

[ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton): Returns the [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) identified by the name.

## 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(text)

Adds a [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) with the specified text to the collection.

| Parameter | Type                                                          | Description                                                                                                                            |
| --------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| **text**  | [String](https://docs.microsoft.com/dotnet/api/system.string) | The text for the [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) that is being added. |

**Returns:** [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton). A [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) that represents the panel that was added to 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) Add(button)

Adds a [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) to the collection.

| Parameter  | Type                                                                                             | Description                                                                                                                                            |
| ---------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **button** | [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) | A [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) that represents the panel to add to the collection. |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The zero-based index of the item in the collection.

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  The [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) being added to the collection is null.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  The parent of the [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) specified in the *button* parameter is not null.

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

Adds an array of [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) to the collection.

| Parameter   | Type                                                                                                 | Description                                                                                                                                 |
| ----------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| **buttons** | [ToolBarButton\[\]](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) | Array of [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) objects to add to 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) Clear()

Removes all [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) objects from 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) Clear(dispose)

Removes and optionally disposes all [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) objects from the collection.

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

### ![](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(button)

Determines whether the specified [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) is located within the collection.

| Parameter  | Type                                                                                             | Description                                                                                                                       |
| ---------- | ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
| **button** | [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) | The [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) to locate in the collection. |

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean). true if the [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) is located within 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) ContainsKey(key)

Determines whether the collection contains a [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) 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 [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) with the specified key; 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) GetEnumerator()

Returns an enumerator to use to iterate through the [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) objects in the 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.

### ![](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(button)

Returns the index within the collection of the specified [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton).

| Parameter  | Type                                                                                             | Description                                                                                                                       |
| ---------- | ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
| **button** | [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) | The [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) to locate in the collection. |

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

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

Returns the index of the first occurrence of a [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) with the specified key.

| Parameter | Type                                                          | Description                                                                                                                                 |
| --------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| **key**   | [String](https://docs.microsoft.com/dotnet/api/system.string) | The name of the [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) 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 [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) with the specified key, if found; otherwise, -1.

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

Inserts the specified [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) 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.                                                                           |
| **button** | [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) | A [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) representing the panel to insert. |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  The *button* parameter is null.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  The *button* 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 [ToolBarButtonCollection](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbar.toolbarbuttoncollection) class.

### ![](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(button)

Removes the specified [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) from the collection.

| Parameter  | Type                                                                                             | Description                                                                                                                                                |
| ---------- | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **button** | [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) | The [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) representing the panel to remove from the collection. |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  The [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) assigned to the *button* parameter is null.

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

Removes the [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) 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 [ToolBarButtonCollection](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbar.toolbarbuttoncollection) class.

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

Removes the [ToolBarButton](https://docs.wisej.com/api/wisej.web/containers/toolbar/wisej.web.toolbarbutton) with the specified key from the collection.

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