Bewerken

Share via


DataGridViewRowCollection Class

Definition

A collection of DataGridViewRow objects.

public ref class DataGridViewRowCollection : System::Collections::IList
[System.ComponentModel.ListBindable(false)]
public class DataGridViewRowCollection : System.Collections.IList
[<System.ComponentModel.ListBindable(false)>]
type DataGridViewRowCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
[<System.ComponentModel.ListBindable(false)>]
type DataGridViewRowCollection = class
    interface ICollection
    interface IEnumerable
    interface IList
Public Class DataGridViewRowCollection
Implements IList
Inheritance
DataGridViewRowCollection
Attributes
Implements

Remarks

The DataGridViewRowCollection contains the DataGridViewRow objects in a DataGridView control. You can retrieve an instance of this class through the control Rows property. The collection maintains a reference to the control through the DataGridView property.

To improve performance, a DataGridViewRowCollection includes shared and unshared rows. Shared rows share memory to reduce the cost of a large record set. If your record set is very large, you should be careful to keep the rows shared as much as possible.

For more information, see Best Practices for Scaling the Windows Forms DataGridView Control.

Constructors

DataGridViewRowCollection(DataGridView)

Initializes a new instance of the DataGridViewRowCollection class.

Properties

Count

Gets the number of rows in the collection.

DataGridView

Gets the DataGridView that owns the collection.

Item[Int32]

Gets the DataGridViewRow at the specified index.

List

Gets an array of DataGridViewRow objects.

Methods

Add()

Adds a new row to the collection.

Add(DataGridViewRow)

Adds the specified DataGridViewRow to the collection.

Add(Int32)

Adds the specified number of new rows to the collection.

Add(Object[])

Adds a new row to the collection, and populates the cells with the specified objects.

AddCopies(Int32, Int32)

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

AddCopy(Int32)

Adds a new row based on the row at the specified index.

AddRange(DataGridViewRow[])

Adds the specified DataGridViewRow objects to the collection.

Clear()

Clears the collection.

Contains(DataGridViewRow)

Determines whether the specified DataGridViewRow is in the collection.

CopyTo(DataGridViewRow[], Int32)

Copies the items from the collection into the specified DataGridViewRow array, starting at the specified index.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetFirstRow(DataGridViewElementStates, DataGridViewElementStates)

Returns the index of the first DataGridViewRow that meets the specified inclusion and exclusion criteria.

GetFirstRow(DataGridViewElementStates)

Returns the index of the first DataGridViewRow that meets the specified criteria.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLastRow(DataGridViewElementStates)

Returns the index of the last DataGridViewRow that meets the specified criteria.

GetNextRow(Int32, DataGridViewElementStates, DataGridViewElementStates)

Returns the index of the next DataGridViewRow that meets the specified inclusion and exclusion criteria.

GetNextRow(Int32, DataGridViewElementStates)

Returns the index of the next DataGridViewRow that meets the specified criteria.

GetPreviousRow(Int32, DataGridViewElementStates, DataGridViewElementStates)

Returns the index of the previous DataGridViewRow that meets the specified inclusion and exclusion criteria.

GetPreviousRow(Int32, DataGridViewElementStates)

Returns the index of the previous DataGridViewRow that meets the specified criteria.

GetRowCount(DataGridViewElementStates)

Returns the number of DataGridViewRow objects in the collection that meet the specified criteria.

GetRowsHeight(DataGridViewElementStates)

Returns the cumulative height of the DataGridViewRow objects that meet the specified criteria.

GetRowState(Int32)

Gets the state of the row with the specified index.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
IndexOf(DataGridViewRow)

Returns the index of a specified item in the collection.

Insert(Int32, DataGridViewRow)

Inserts the specified DataGridViewRow into the collection.

Insert(Int32, Int32)

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

Insert(Int32, Object[])

Inserts a row into the collection at the specified position, and populates the cells with the specified objects.

InsertCopies(Int32, Int32, Int32)

Inserts rows into the collection at the specified position.

InsertCopy(Int32, Int32)

Inserts a row into the collection at the specified position, based on the row at specified position.

InsertRange(Int32, DataGridViewRow[])

Inserts the DataGridViewRow objects into the collection at the specified position.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OnCollectionChanged(CollectionChangeEventArgs)

Raises the CollectionChanged event.

Remove(DataGridViewRow)

Removes the row from the collection.

RemoveAt(Int32)

Removes the row at the specified position from the collection.

SharedRow(Int32)

Returns the DataGridViewRow at the specified index.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Events

CollectionChanged

Occurs when the contents of the collection change.

Explicit Interface Implementations

ICollection.CopyTo(Array, Int32)

Copies the elements of the collection to an Array, starting at the specified index.

ICollection.Count

Gets the number of elements contained in the collection.

ICollection.IsSynchronized

Gets a value indicating whether access to the collection is synchronized (thread safe).

ICollection.SyncRoot

Gets an object that can be used to synchronize access to the collection.

IEnumerable.GetEnumerator()

Returns an enumerator that iterates through the collection.

IList.Add(Object)

Adds a DataGridViewRow to the collection.

IList.Clear()

Removes all items from the collection.

IList.Contains(Object)

Determines whether the collection contains the specified item.

IList.IndexOf(Object)

Returns the index of a specified item in the collection.

IList.Insert(Int32, Object)

Inserts a DataGridViewRow into the collection at the specified index.

IList.IsFixedSize

Gets a value indicating whether the collection has a fixed size.

IList.IsReadOnly

Gets a value indicating whether the collection is read-only.

IList.Item[Int32]

Gets or sets the element at the specified index.

IList.Remove(Object)

Removes the specified DataGridViewRow from the collection.

IList.RemoveAt(Int32)

Removes the DataGridViewRow from the collection at the specified position.

Extension Methods

Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Applies to

See also