# DataGridViewSelectedCellCollection

Namespace: **Wisej.Web**

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

* [BaseCollection](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.basecollection)
  * [DataGridViewSelectedCellCollection](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewselectedcellcollection)

Represents a collection of cells that are selected in a [DataGridView](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview).

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

```csharp
public class DataGridViewSelectedCellCollection : BaseCollection, IList, IList<DataGridViewCell>, ICollection<DataGridViewCell>, IEnumerable<DataGridViewCell>
```

{% endtab %}

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

```visual-basic
Public Class DataGridViewSelectedCellCollection
    Inherits BaseCollection
    Implements IList, IList(Of DataGridViewCell), ICollection(Of DataGridViewCell), IEnumerable(Of DataGridViewCell)
```

{% endtab %}
{% endtabs %}

## 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) Count

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Returns the number of elements in 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) Item(index)

[DataGridViewCell](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell): Returns the cell at the specified index.

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception) *index* is less than 0; or *index* is equal to or greater than the number of cells in 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) List

[IList](https://docs.microsoft.com/dotnet/api/system.collections.ilist): Returns a list of elements in the collection.

## 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) Contains(cellAddress)

Determines whether the specified cell is contained in the collection.

| Parameter       | Type                                                                | Description                                                                                                                                                                                                                                                                                 |
| --------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **cellAddress** | [Point](https://docs.microsoft.com/dotnet/api/system.drawing.point) | The [DataGridViewCell](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) to locate in the [DataGridViewSelectedCellCollection](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewselectedcellcollection). |

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean). true if *cellAddress* is in the [DataGridViewSelectedCellCollection](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewselectedcellcollection); 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) Contains(cell)

Determines whether the specified cell is contained in the collection.

| Parameter | Type                                                                                                             | Description                                                                                                                                                                                                                                                                                 |
| --------- | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **cell**  | [DataGridViewCell](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) | The [DataGridViewCell](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) to locate in the [DataGridViewSelectedCellCollection](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewselectedcellcollection). |

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean). true if *cell* is in the [DataGridViewSelectedCellCollection](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewselectedcellcollection); 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) CopyTo(array, index)

Copies the elements of the collection to the specified [DataGridViewCell](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) array, starting at the specified index.

| Parameter | Type                                                                                                                 | Description                                                                                                                                                                                                                                                     |
| --------- | -------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **array** | [DataGridViewCell\[\]](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) | The one-dimensional array of type [DataGridViewCell](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) that is the destination of the elements copied from the collection. The array must have zero-based indexing. |
| **index** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32)                                                          | The zero-based index in *array* at which copying begins.                                                                                                                                                                                                        |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception) *array* is null.
* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception) *index* is less than zero.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception) *array* is multidimensional; or the number of elements in the [DataGridViewSelectedCellCollection](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewselectedcellcollection) is greater than the available space from *index* to the end of *array* .
* [InvalidCastException](https://docs.microsoft.com/dotnet/api/system.invalidcastexception) The [DataGridViewSelectedCellCollection](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewselectedcellcollection) cannot be cast automatically to the type of *array* .

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

Returns the index of the specified element.

| Parameter       | Type                                                                | Description                                                                                                                                       |
| --------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| **cellAddress** | [Point](https://docs.microsoft.com/dotnet/api/system.drawing.point) | The [DataGridViewCell](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) to locate in the collection. |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The zero-based index of the *cellAddress* parameter if it is found in the collection; 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) IndexOf(cell)

Returns the index of the specified element.

| Parameter | Type                                                                                                             | Description                                                                                                                                       |
| --------- | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| **cell**  | [DataGridViewCell](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) | The [DataGridViewCell](https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) to locate in the collection. |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The zero-based index of the *cell* parameter if it is found in the collection; otherwise, -1.
