# DataGridViewSelectedCellCollection

Namespace: **Wisej.Web**

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

* [BaseCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.basecollection.md)
  * [DataGridViewSelectedCellCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewselectedcellcollection.md)

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

{% 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

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

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

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

[DataGridViewCell](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell.md): 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.

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

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

## Methods

### ![](/files/hsR4ok3152WyAf8J2C1u) 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](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell.md) to locate in the [DataGridViewSelectedCellCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewselectedcellcollection.md). |

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean). true if *cellAddress* is in the [DataGridViewSelectedCellCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewselectedcellcollection.md); otherwise, false.

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

Determines whether the specified cell is contained in the collection.

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

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean). true if *cell* is in the [DataGridViewSelectedCellCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewselectedcellcollection.md); otherwise, false.

### ![](/files/hsR4ok3152WyAf8J2C1u) CopyTo(array, index)

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

| Parameter | Type                                                                                              | Description                                                                                                                                                                                                                                  |
| --------- | ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **array** | [DataGridViewCell\[\]](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell.md) | The one-dimensional array of type [DataGridViewCell](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell.md) 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](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewselectedcellcollection.md) is greater than the available space from *index* to the end of *array* .
* [InvalidCastException](https://docs.microsoft.com/dotnet/api/system.invalidcastexception) The [DataGridViewSelectedCellCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewselectedcellcollection.md) cannot be cast automatically to the type of *array* .

### ![](/files/hsR4ok3152WyAf8J2C1u) 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](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell.md) 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.

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

Returns the index of the specified element.

| Parameter | Type                                                                                          | Description                                                                                                                    |
| --------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| **cell**  | [DataGridViewCell](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell.md) | The [DataGridViewCell](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell.md) 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.


---

# 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/datagridview/wisej.web.datagridviewselectedcellcollection.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.
