# DataGridViewRowCollection

Namespace: **Wisej.Web**

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

A collection of [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) objects.

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

```csharp
public class DataGridViewRowCollection : IList, ICollection, IEnumerable, IList<DataGridViewRow>, ICollection<DataGridViewRow>, IEnumerable<DataGridViewRow>
```

{% endtab %}

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

```visual-basic
Public Class DataGridViewRowCollection
    Inherits IList
    Implements ICollection, IEnumerable, IList(Of DataGridViewRow), ICollection(Of DataGridViewRow), IEnumerable(Of DataGridViewRow)
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](/files/hsR4ok3152WyAf8J2C1u) DataGridViewRowCollection(dataGrid)

Initializes a new instance of the [DataGridViewRowCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrowcollection.md) class for the given [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md).

| Name         | Type                                                           | Description                                                                                      |
| ------------ | -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| **dataGrid** | [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) | The [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) that created this collection. |

## Properties

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

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

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

[DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md): Returns the [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) 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 [Count](#count).

## Methods

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

Adds a new [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) to the collection.

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The index of the new [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md).

**Throws:**

* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  The row returned by the [RowTemplate](/api/wisej.web/lists-and-grids/datagridview.md#rowtemplate) property has more cells than there are columns in the control.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents new rows from being added:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)

Or the [DataSource](/api/wisej.web/lists-and-grids/datagridview.md#datasource) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is not null.\
Or the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) has no columns.

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

Adds a new [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) to the collection, and populates the cells with the specified objects.

| Parameter  | Type                                                              | Description                                                                                                                                                  |
| ---------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **values** | [Object\[\]](https://docs.microsoft.com/dotnet/api/system.object) | A variable number of objects that populate the cells of the new [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The index of the new [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md).

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)*values* is null.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents new rows from being added:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)

Or the [DataSource](/api/wisej.web/lists-and-grids/datagridview.md#datasource) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is not null.\
Or the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) has no columns.\
Or the [VirtualMode](/api/wisej.web/lists-and-grids/datagridview.md#virtualmode) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is set to true.\
Or the row returned by the [RowTemplate](/api/wisej.web/lists-and-grids/datagridview.md#rowtemplate) property has more cells than there are columns in the control.

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

Adds the specified [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) to the collection.

| Parameter | Type                                                                                        | Description                                                                                                                                                                                                                    |
| --------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **row**   | [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) | The [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) to add to the [DataGridViewRowCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrowcollection.md). |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The index of the new [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md).

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)*row* is null.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)*row* has more cells than there are columns in the control.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents new rows from being added:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)

Or the [DataSource](/api/wisej.web/lists-and-grids/datagridview.md#datasource) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is not null.\
Or the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) has no columns.

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

Adds the specified number of new rows to the collection.

| Parameter | Type                                                        | Description                                                                                                                                       |
| --------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| **count** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The number of rows to add to the [DataGridViewRowCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrowcollection.md). |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The index of the last row that was added.

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)*count* is less than 1.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents new rows from being added:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)

Or the [DataSource](/api/wisej.web/lists-and-grids/datagridview.md#datasource) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is not null.\
Or the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) has no columns.

### ![](/files/hsR4ok3152WyAf8J2C1u) AddCopies(rowIndex, count)

Adds the specified number of rows to the collection based on the row at the specified index.

| Parameter    | Type                                                        | Description                                                                                                                                       |
| ------------ | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| **rowIndex** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The index of the row on which to base the new rows.                                                                                               |
| **count**    | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The number of rows to add to the [DataGridViewRowCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrowcollection.md). |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The index of the last row that was added.

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)*rowIndex* is less than zero or greater than or equal to the number of rows in the control; or *count* is less than zero.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents new rows from being added:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)\
  Or the [DataSource](/api/wisej.web/lists-and-grids/datagridview.md#datasource) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is not null.

### ![](/files/hsR4ok3152WyAf8J2C1u) AddCopy(rowIndex)

Adds a [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) row based on the [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) at the specified index.

| Parameter    | Type                                                        | Description                                        |
| ------------ | ----------------------------------------------------------- | -------------------------------------------------- |
| **rowIndex** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The index of the row on which to base the new row. |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The index of the new [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md).

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)*rowIndex* is less than zero or greater than or equal to the number of rows in the collection.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents new rows from being added:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)\
  Or the [DataSource](/api/wisej.web/lists-and-grids/datagridview.md#datasource) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is not null.

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

Adds the specified [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) objects to the collection.

| Parameter   | Type                                                                                            | Description                                                                                                                                                                                                                                         |
| ----------- | ----------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **newRows** | [DataGridViewRow\[\]](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) | An array of [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) objects to be added to the [DataGridViewRowCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrowcollection.md). |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)*newRows* is null.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)*newRows* contains only one row, and the row it contains has more cells than there are columns in the control.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents new rows from being added:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)\
  Or the [DataSource](/api/wisej.web/lists-and-grids/datagridview.md#datasource) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is not null.

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

Clears the collection.

**Throws:**

* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The collection is data bound and the underlying data source does not support clearing the row data. Or the associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents the row collection from being modified:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)

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

Determines whether the specified [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) is in the collection.

| Parameter | Type                                                                                        | Description                                                                                                                                                                                                                       |
| --------- | ------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **row**   | [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) | The [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) to locate in the [DataGridViewRowCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrowcollection.md). |

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

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

Copies the items from the collection into the specified [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) array, starting at the specified index.

| Parameter | Type                                                                                            | Description                                                                                                                                                                                                                                                               |
| --------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **array** | [DataGridViewRow\[\]](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) | A [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) array that is the destination of the items copied from the [DataGridViewRowCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrowcollection.md). |
| **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 [DataGridViewRowCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrowcollection.md) is greater than the available space from *index* to the end of *array* .

### ![](/files/hsR4ok3152WyAf8J2C1u) GetFirstRow(includeFilter, excludeFilter)

Returns the first [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) that matches the specified *includeFilter* and *excludeFilter* .

| Parameter                                          | Type                                                                                                            | Description                                                                                                                                      |
| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| **includeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values. |
| **excludeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values. |

**Returns:** [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). The first [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) that matches the specified filters; or null if no row is found.

**Throws:**

* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  One or both of the specified filter values is not a valid combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.

### ![](/files/hsR4ok3152WyAf8J2C1u) GetFirstRowIndex(includeFilter, excludeFilter)

Returns the index of the first [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) that matches the specified *includeFilter* and *excludeFilter* .

| Parameter                                          | Type                                                                                                            | Description                                                                                                                                      |
| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| **includeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values. |
| **excludeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values. |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The index of the first [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) that matches the specified filters; or -1 if no row is found.

**Throws:**

* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  One or both of the specified filter values is not a valid combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.

### ![](/files/hsR4ok3152WyAf8J2C1u) GetLastRow(includeFilter, excludeFilter)

Returns the last [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) that matches the *includeFilter* and *excludeFilter* .

| Parameter                                          | Type                                                                                                            | Description                                                                                                                                      |
| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| **includeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values. |
| **excludeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values. |

**Returns:** [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). The last [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) that matches the specified filter; or null if no row is found.

**Throws:**

* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)*includeFilter* is not a valid bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.

### ![](/files/hsR4ok3152WyAf8J2C1u) GetLastRowIndex(includeFilter, excludeFilter)

Returns the index of the last [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) that matches the *includeFilter* and *excludeFilter* .

| Parameter                                          | Type                                                                                                            | Description                                                                                                                                      |
| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| **includeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values. |
| **excludeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values. |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The index of the last [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) that matches the specified filter; or -1 if no row is found.

**Throws:**

* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)*includeFilter* is not a valid bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.

### ![](/files/hsR4ok3152WyAf8J2C1u) GetNextRow(startRow, includeFilter, excludeFilter)

Returns the next [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) after *startRow* that matches the *includeFilter* and *excludeFilter* .

| Parameter                                          | Type                                                                                                            | Description                                                                                                                                             |
| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **startRow**                                       | [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md)                     | The row where the method should begin to look for the next [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). |
| **includeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.        |
| **excludeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.        |

**Returns:** [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). The next [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) that matches the filters; or null if no row is found after *startRow* .

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)*startRow* is null.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  One or both of the specified filter values is not a valid bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.

### ![](/files/hsR4ok3152WyAf8J2C1u) GetNextRow(startIndex, includeFilter, excludeFilter)

Returns the next [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) after *startIndex* that matches the *includeFilter* and *excludeFilter* .

| Parameter                                          | Type                                                                                                            | Description                                                                                                                                                          |
| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **startIndex**                                     | [Int32](https://docs.microsoft.com/dotnet/api/system.int32)                                                     | The index of the row where the method should begin to look for the next [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). |
| **includeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.                     |
| **excludeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.                     |

**Returns:** [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). The next [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) that matches the filters; or null if no row is found after *startIndex* .

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)*startIndex* is less than -1.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  One or both of the specified filter values is not a valid bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.

### ![](/files/hsR4ok3152WyAf8J2C1u) GetNextRowIndex(startRow, includeFilter, excludeFilter)

Returns the index of the next [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) after *startRow* that matches the *includeFilter* and *excludeFilter* .

| Parameter                                          | Type                                                                                                            | Description                                                                                                                                             |
| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **startRow**                                       | [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md)                     | The row where the method should begin to look for the next [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). |
| **includeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.        |
| **excludeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.        |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The index of the next [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) that matches the filters; or -1 if no row is found after *startRow* .

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)*startRow* is null.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  One or both of the specified filter values is not a valid bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.

### ![](/files/hsR4ok3152WyAf8J2C1u) GetNextRowIndex(startIndex, includeFilter, excludeFilter)

Returns the index of the next [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) after *startIndex* that matches the *includeFilter* and *excludeFilter* .

| Parameter                                          | Type                                                                                                            | Description                                                                                                                                                          |
| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **startIndex**                                     | [Int32](https://docs.microsoft.com/dotnet/api/system.int32)                                                     | The index of the row where the method should begin to look for the next [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). |
| **includeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.                     |
| **excludeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.                     |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The index of the next [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) that matches the filters; or -1 if no row is found after *startIndex* .

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)*startIndex* is less than -1.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  One or both of the specified filter values is not a valid bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.

### ![](/files/hsR4ok3152WyAf8J2C1u) GetPreviousRow(startRow, includeFilter, excludeFilter)

Returns the previous [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) before *startRow* that matches the *includeFilter* and *excludeFilter* .

| Parameter                                          | Type                                                                                                            | Description                                                                                                                                                 |
| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **startRow**                                       | [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md)                     | The row where the method should begin to look for the previous [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). |
| **includeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.            |
| **excludeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.            |

**Returns:** [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). The previous [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) that matches the filters; or null if no row is found before *startRow* .

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)*startRow* is null.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  One or both of the specified filter values is not a valid bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.

### ![](/files/hsR4ok3152WyAf8J2C1u) GetPreviousRow(startIndex, includeFilter, excludeFilter)

Returns the previous [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) before *startIndex* that matches the *includeFilter* and *excludeFilter* .

| Parameter                                          | Type                                                                                                            | Description                                                                                                                                                              |
| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **startIndex**                                     | [Int32](https://docs.microsoft.com/dotnet/api/system.int32)                                                     | The index of the row where the method should begin to look for the previous [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). |
| **includeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.                         |
| **excludeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.                         |

**Returns:** [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). The previous [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) that matches the filters; or null if no row is found before *startIndex* .

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)*startIndex* is greater than the number of rows in the collection.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  One or both of the specified filter values is not a valid bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.

### ![](/files/hsR4ok3152WyAf8J2C1u) GetPreviousRowIndex(startRow, includeFilter, excludeFilter)

Returns the index of the previous [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) before *startRow* that matches the *includeFilter* and *excludeFilter* .

| Parameter                                          | Type                                                                                                            | Description                                                                                                                                                 |
| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **startRow**                                       | [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md)                     | The row where the method should begin to look for the previous [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). |
| **includeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.            |
| **excludeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.            |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The index of previous [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) that matches the filters; or -1 if no row is found before *startRow* .

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)*startRow* is null.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  One or both of the specified filter values is not a valid bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.

### ![](/files/hsR4ok3152WyAf8J2C1u) GetPreviousRowIndex(startIndex, includeFilter, excludeFilter)

Returns the index of the previous [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) before *startIndex* that matches the *includeFilter* and *excludeFilter* .

| Parameter                                          | Type                                                                                                            | Description                                                                                                                                                              |
| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **startIndex**                                     | [Int32](https://docs.microsoft.com/dotnet/api/system.int32)                                                     | The index of the row where the method should begin to look for the previous [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). |
| **includeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.                         |
| **excludeFilter** ![](/files/1vGqtbG2j637vQ4ROWOf) | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.                         |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The index of the previous [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) that matches the filters; or -1 if no row is found before *startIndex* .

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)*startIndex* is greater than the number of rows in the collection.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  One or both of the specified filter values is not a valid bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.

### ![](/files/hsR4ok3152WyAf8J2C1u) GetRowCount(includeFilter)

Returns the number of rows that match the *includeFilter* .

| Parameter         | Type                                                                                                            | Description                                                                                                                                                |
| ----------------- | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **includeFilter** | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A combination of the [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values for inclusion. |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The number of rows that match the *includeFilter* .

**Throws:**

* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)*includeFilter* is not a valid bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.

### ![](/files/hsR4ok3152WyAf8J2C1u) GetRowsHeight(includeFilter)

Returns the cumulative height of the [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) objects that match the *includeFilter* .

| Parameter         | Type                                                                                                            | Description                                                                                                                                      |
| ----------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| **includeFilter** | [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) | A bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values. |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The cumulative height of [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) objects that match the *includeFilter* .

**Throws:**

* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)*includeFilter* is not a valid bitwise combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values.

### ![](/files/hsR4ok3152WyAf8J2C1u) GetRowState(rowIndex)

Returns the state of the [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) at the specified index.

| Parameter    | Type                                                        | Description           |
| ------------ | ----------------------------------------------------------- | --------------------- |
| **rowIndex** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The index of the row. |

**Returns:** [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md). A combination of [DataGridViewElementStates](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelementstates.md) values indicating the state of the row.

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)*rowIndex* is less than zero and greater than the number of rows in the collection.

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

Returns the index of the given [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) in the collection.

| Parameter | Type                                                                                        | Description                                                                                                             |
| --------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| **row**   | [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) | The [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) to return the index of. |

**Returns:** [Int32](https://docs.microsoft.com/dotnet/api/system.int32). The index of the given [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md).

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

Inserts a [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) into the collection at the specified position.

| Parameter | Type                                                        | Description                                                                                                                      |
| --------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| **index** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The position at which to insert the [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). |

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)*index* is less than zero or greater than the number of rows in the collection.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  The row returned by the control's [RowTemplate](/api/wisej.web/lists-and-grids/datagridview.md#rowtemplate) property has more cells than there are columns in the control.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents new rows from being added:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)

Or the [DataSource](/api/wisej.web/lists-and-grids/datagridview.md#datasource) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is not null.\
Or the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) has no columns.\
Or the [VirtualMode](/api/wisej.web/lists-and-grids/datagridview.md#virtualmode) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is set to true.\
Or the row returned by the [RowTemplate](/api/wisej.web/lists-and-grids/datagridview.md#rowtemplate) property has more cells than there are columns in the control.

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

Inserts a [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) into the collection at the specified position, and populates the cells with the specified objects.

| Parameter  | Type                                                              | Description                                                                                                                                                  |
| ---------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **index**  | [Int32](https://docs.microsoft.com/dotnet/api/system.int32)       | The position at which to insert the [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md).                             |
| **values** | [Object\[\]](https://docs.microsoft.com/dotnet/api/system.object) | A variable number of objects that populate the cells of the new [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). |

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)*index* is less than zero or greater than the number of rows in the collection.
* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)*values* is null.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  The row returned by the control's [RowTemplate](/api/wisej.web/lists-and-grids/datagridview.md#rowtemplate) property has more cells than there are columns in the control.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents new rows from being added:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)

Or the [DataSource](/api/wisej.web/lists-and-grids/datagridview.md#datasource) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is not null.\
Or the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) has no columns.\
Or the [VirtualMode](/api/wisej.web/lists-and-grids/datagridview.md#virtualmode) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is set to true.\
Or the row returned by the [RowTemplate](/api/wisej.web/lists-and-grids/datagridview.md#rowtemplate) property has more cells than there are columns in the control.

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

Inserts the specified [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) into the collection.

| Parameter | Type                                                                                        | Description                                                                                                                                                                                                                         |
| --------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **index** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32)                                 | The position at which to insert the row.                                                                                                                                                                                            |
| **row**   | [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) | The [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) to insert into the [DataGridViewRowCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrowcollection.md). |

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)*index* is less than zero or greater than the number of rows in the collection.
* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)*row* is null.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)*row* has more cells than there are columns in the control.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents new rows from being added:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)

Or the [DataSource](/api/wisej.web/lists-and-grids/datagridview.md#datasource) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is not null.\
Or the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) has no columns.

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

Inserts the specified number of rows into the collection at the specified location.

| Parameter | Type                                                        | Description                                                                                                                                            |
| --------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **index** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The position at which to insert the rows.                                                                                                              |
| **count** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The number of rows to insert into the [DataGridViewRowCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrowcollection.md). |

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)*index* is less than zero or greater than the number of rows in the collection; or *count* is less than 1.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents new rows from being added:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)

Or the [DataSource](/api/wisej.web/lists-and-grids/datagridview.md#datasource) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is not null.\
Or the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) has no columns.

### ![](/files/hsR4ok3152WyAf8J2C1u) InsertCopies(indexSource, indexDestination, count)

Inserts rows into the collection at the specified position.

| Parameter            | Type                                                        | Description                                                                                                                                                                                                                                      |
| -------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **indexSource**      | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The index of the [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) on which to base the new rows.                                                                                                      |
| **indexDestination** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The position at which to insert the rows.                                                                                                                                                                                                        |
| **count**            | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The number of [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) objects to add to the [DataGridViewRowCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrowcollection.md). |

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)*indexSource* is less than zero or greater than the number of rows in the collection minus one; or *indexDestination* is less than zero or greater than the number of rows in the collection; or *count* is less than 1.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents new rows from being added:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)\
  Or the [DataSource](/api/wisej.web/lists-and-grids/datagridview.md#datasource) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is not null.

### ![](/files/hsR4ok3152WyAf8J2C1u) InsertCopy(indexSource, indexDestination)

Inserts a new [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) into the collection at the specified *indexDestination* , based on the [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) at *indexSource* .

| Parameter            | Type                                                        | Description                                                                                                                                                                                                                        |
| -------------------- | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **indexSource**      | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The index of the [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) on which to base the new [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md). |
| **indexDestination** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The position at which to insert the row.                                                                                                                                                                                           |

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)*indexSource* is less than zero or greater than the number of rows in the collection minus one; or *indexDestination* is less than zero or greater than the number of rows in the collection.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents new rows from being added:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)\
  Or the [DataSource](/api/wisej.web/lists-and-grids/datagridview.md#datasource) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is not null.

### ![](/files/hsR4ok3152WyAf8J2C1u) InsertRange(index, newRows)

Inserts the [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) objects into the collection at the specified position.

| Parameter   | Type                                                                                            | Description                                                                                                                                                                                                                                    |
| ----------- | ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **index**   | [Int32](https://docs.microsoft.com/dotnet/api/system.int32)                                     | The position at which to insert the rows.                                                                                                                                                                                                      |
| **newRows** | [DataGridViewRow\[\]](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) | An array of [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) objects to add to the [DataGridViewRowCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrowcollection.md). |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)*newRows* is null.
* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)*index* is less than zero or greater than the number of rows in the collection.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)*newRows* contains only one row, and the row it contains has more cells than there are columns in the control.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents new rows from being added:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)\
  Or the [DataSource](/api/wisej.web/lists-and-grids/datagridview.md#datasource) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is not null.

### ![](/files/lzopMboA31bVq8UIcbT3) OnCollectionChanged(action, element, recreateNewRow)

Fires the [CollectionChanged](#collectionchanged) event.

| Parameter                                           | Type                                                                                                         | Description                                                                                                                                                           |
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **action**                                          | [CollectionChangeAction](https://docs.microsoft.com/dotnet/api/system.componentmodel.collectionchangeaction) | One of [CollectionChangeAction](https://docs.microsoft.com/dotnet/api/system.componentmodel.collectionchangeaction) indicating the reason the collection has changed. |
| **element**                                         | [Object](https://docs.microsoft.com/dotnet/api/system.object)                                                | The element that was added or removed from the collection, or null.                                                                                                   |
| **recreateNewRow** ![](/files/1vGqtbG2j637vQ4ROWOf) | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean)                                              | Indicates whether the grid should re-create the new automatic row.                                                                                                    |

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

Removes the row from the collection.

| Parameter | Type                                                                                        | Description                                                                                                                                 |
| --------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| **row**   | [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) | The row to remove from the [DataGridViewRowCollection](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrowcollection.md). |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)*row* is null.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)*row* is not contained in this collection; or *row* is a shared row.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents new rows from being added:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)

Or the [DataSource](/api/wisej.web/lists-and-grids/datagridview.md#datasource) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is not null.\
Or the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) has no columns.

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

Removes the [DataGridViewRow](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewrow.md) at the specified position from the collection.

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

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)*index* is less than zero and greater than the number of rows in the collection minus one.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The associated [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) control is performing one of the following actions that temporarily prevents new rows from being added:
* Selecting all cells in the control.
* Clearing the selection.\
  Or this method is being called from a handler for one of the following [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) events:
* [CellEnter](/api/wisej.web/lists-and-grids/datagridview.md#cellenter)
* [CellLeave](/api/wisej.web/lists-and-grids/datagridview.md#cellleave)
* [CellValidating](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidating)
* [CellValidated](/api/wisej.web/lists-and-grids/datagridview.md#cellvalidated)
* [RowEnter](/api/wisej.web/lists-and-grids/datagridview.md#rowenter)
* [RowLeave](/api/wisej.web/lists-and-grids/datagridview.md#rowleave)
* [RowValidated](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidated)
* [RowValidating](/api/wisej.web/lists-and-grids/datagridview.md#rowvalidating)

Or the [DataSource](/api/wisej.web/lists-and-grids/datagridview.md#datasource) property of the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) is not null.\
Or the [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) has no columns.

## Events

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

[CollectionChangeEventHandler](https://docs.microsoft.com/dotnet/api/system.componentmodel.collectionchangeeventhandler) Fired when the collection changes.


---

# 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.datagridviewrowcollection.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.
