DataGridViewRowCollection DataGridViewRowCollection DataGridViewRowCollection DataGridViewRowCollection Class

定义

DataGridViewRow 对象的集合。A collection of DataGridViewRow objects.

public ref class DataGridViewRowCollection : System::Collections::IList
[System.ComponentModel.ListBindable(false)]
public class DataGridViewRowCollection : System.Collections.IList
type DataGridViewRowCollection = class
    interface ICollection
    interface IEnumerable
    interface IList
Public Class DataGridViewRowCollection
Implements IList
继承
DataGridViewRowCollectionDataGridViewRowCollectionDataGridViewRowCollectionDataGridViewRowCollection
属性
实现

注解

DataGridViewRowCollection包含DataGridViewRow中的对象DataGridView控件。The DataGridViewRowCollection contains the DataGridViewRow objects in a DataGridView control. 可以检索通过控件的此类的实例Rows属性。You can retrieve an instance of this class through the control Rows property. 集合将保留通过对控件的引用DataGridView属性。The collection maintains a reference to the control through the DataGridView property.

若要提高性能,DataGridViewRowCollection包括共享和非共享行。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.

有关详细信息,请参阅缩放 Windows 窗体 DataGridView 控件的最佳做法For more information, see Best Practices for Scaling the Windows Forms DataGridView Control.

构造函数

DataGridViewRowCollection(DataGridView) DataGridViewRowCollection(DataGridView) DataGridViewRowCollection(DataGridView) DataGridViewRowCollection(DataGridView)

初始化 DataGridViewRowCollection 类的新实例。Initializes a new instance of the DataGridViewRowCollection class.

属性

Count Count Count Count

获取集合中的行数。Gets the number of rows in the collection.

DataGridView DataGridView DataGridView DataGridView

获取拥有集合的 DataGridViewGets the DataGridView that owns the collection.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

获取位于指定索引处的 DataGridViewRowGets the DataGridViewRow at the specified index.

List List List List

获取 DataGridViewRow 对象数组。Gets an array of DataGridViewRow objects.

方法

Add() Add() Add() Add()

向集合添加新行。Adds a new row to the collection.

Add(DataGridViewRow) Add(DataGridViewRow) Add(DataGridViewRow) Add(DataGridViewRow)

将指定的 DataGridViewRow 添加到集合。Adds the specified DataGridViewRow to the collection.

Add(Int32) Add(Int32) Add(Int32) Add(Int32)

将指定的新行数添加到集合中。Adds the specified number of new rows to the collection.

Add(Object[]) Add(Object[]) Add(Object[]) Add(Object[])

将新行添加到集合中,并使用指定的对象填充单元格。Adds a new row to the collection, and populates the cells with the specified objects.

AddCopies(Int32, Int32) AddCopies(Int32, Int32) AddCopies(Int32, Int32) AddCopies(Int32, Int32)

将指定的行数添加到基于指定索引处的行的集合。Adds the specified number of rows to the collection based on the row at the specified index.

AddCopy(Int32) AddCopy(Int32) AddCopy(Int32) AddCopy(Int32)

基于指定索引处的行添加新的一行。Adds a new row based on the row at the specified index.

AddRange(DataGridViewRow[]) AddRange(DataGridViewRow[]) AddRange(DataGridViewRow[]) AddRange(DataGridViewRow[])

将指定的 DataGridViewRow 对象添加到集合中。Adds the specified DataGridViewRow objects to the collection.

Clear() Clear() Clear() Clear()

清除集合。Clears the collection.

Contains(DataGridViewRow) Contains(DataGridViewRow) Contains(DataGridViewRow) Contains(DataGridViewRow)

确定指定的 DataGridViewRow 是否在集合中。Determines whether the specified DataGridViewRow is in the collection.

CopyTo(DataGridViewRow[], Int32) CopyTo(DataGridViewRow[], Int32) CopyTo(DataGridViewRow[], Int32) CopyTo(DataGridViewRow[], Int32)

从指定索引处开始,将集合中的项复制到指定的 DataGridViewRow 数组。Copies the items from the collection into the specified DataGridViewRow array, starting at the specified index.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetFirstRow(DataGridViewElementStates) GetFirstRow(DataGridViewElementStates) GetFirstRow(DataGridViewElementStates) GetFirstRow(DataGridViewElementStates)

返回满足指定条件的第一个 DataGridViewRow 的索引。Returns the index of the first DataGridViewRow that meets the specified criteria.

GetFirstRow(DataGridViewElementStates, DataGridViewElementStates) GetFirstRow(DataGridViewElementStates, DataGridViewElementStates) GetFirstRow(DataGridViewElementStates, DataGridViewElementStates) GetFirstRow(DataGridViewElementStates, DataGridViewElementStates)

返回满足指定的包含和排除条件的第一个 DataGridViewRow 的索引。Returns the index of the first DataGridViewRow that meets the specified inclusion and exclusion criteria.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetLastRow(DataGridViewElementStates) GetLastRow(DataGridViewElementStates) GetLastRow(DataGridViewElementStates) GetLastRow(DataGridViewElementStates)

返回满足指定条件的最后一个 DataGridViewRow 的索引。Returns the index of the last DataGridViewRow that meets the specified criteria.

GetNextRow(Int32, DataGridViewElementStates) GetNextRow(Int32, DataGridViewElementStates) GetNextRow(Int32, DataGridViewElementStates) GetNextRow(Int32, DataGridViewElementStates)

返回满足指定条件的下一个 DataGridViewRow 的索引。Returns the index of the next DataGridViewRow that meets the specified criteria.

GetNextRow(Int32, DataGridViewElementStates, DataGridViewElementStates) GetNextRow(Int32, DataGridViewElementStates, DataGridViewElementStates) GetNextRow(Int32, DataGridViewElementStates, DataGridViewElementStates) GetNextRow(Int32, DataGridViewElementStates, DataGridViewElementStates)

返回下一个满足指定包含和排除条件的 DataGridViewRow 的索引。Returns the index of the next DataGridViewRow that meets the specified inclusion and exclusion criteria.

GetPreviousRow(Int32, DataGridViewElementStates) GetPreviousRow(Int32, DataGridViewElementStates) GetPreviousRow(Int32, DataGridViewElementStates) GetPreviousRow(Int32, DataGridViewElementStates)

返回满足指定条件的前一个 DataGridViewRow 的索引。Returns the index of the previous DataGridViewRow that meets the specified criteria.

GetPreviousRow(Int32, DataGridViewElementStates, DataGridViewElementStates) GetPreviousRow(Int32, DataGridViewElementStates, DataGridViewElementStates) GetPreviousRow(Int32, DataGridViewElementStates, DataGridViewElementStates) GetPreviousRow(Int32, DataGridViewElementStates, DataGridViewElementStates)

返回满足指定的包含和排除条件的上一个 DataGridViewRow 的索引。Returns the index of the previous DataGridViewRow that meets the specified inclusion and exclusion criteria.

GetRowCount(DataGridViewElementStates) GetRowCount(DataGridViewElementStates) GetRowCount(DataGridViewElementStates) GetRowCount(DataGridViewElementStates)

返回集合中符合指定的条件的 DataGridViewRow 对象的数目。Returns the number of DataGridViewRow objects in the collection that meet the specified criteria.

GetRowsHeight(DataGridViewElementStates) GetRowsHeight(DataGridViewElementStates) GetRowsHeight(DataGridViewElementStates) GetRowsHeight(DataGridViewElementStates)

返回满足指定条件的 DataGridViewRow 对象的累积高度。Returns the cumulative height of the DataGridViewRow objects that meet the specified criteria.

GetRowState(Int32) GetRowState(Int32) GetRowState(Int32) GetRowState(Int32)

获取具有指定索引的行的状态。Gets the state of the row with the specified index.

GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
IndexOf(DataGridViewRow) IndexOf(DataGridViewRow) IndexOf(DataGridViewRow) IndexOf(DataGridViewRow)

返回集合中的指定项的索引。Returns the index of a specified item in the collection.

Insert(Int32, DataGridViewRow) Insert(Int32, DataGridViewRow) Insert(Int32, DataGridViewRow) Insert(Int32, DataGridViewRow)

将指定的 DataGridViewRow 插入集合中。Inserts the specified DataGridViewRow into the collection.

Insert(Int32, Int32) Insert(Int32, Int32) Insert(Int32, Int32) Insert(Int32, Int32)

在集合的指定位置插入指定数量的行。Inserts the specified number of rows into the collection at the specified location.

Insert(Int32, Object[]) Insert(Int32, Object[]) Insert(Int32, Object[]) 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) InsertCopies(Int32, Int32, Int32) InsertCopies(Int32, Int32, Int32) InsertCopies(Int32, Int32, Int32)

将行插入集合中的指定位置。Inserts rows into the collection at the specified position.

InsertCopy(Int32, Int32) InsertCopy(Int32, Int32) InsertCopy(Int32, Int32) InsertCopy(Int32, Int32)

基于指定位置的行,将行插入指定位置的集合中。Inserts a row into the collection at the specified position, based on the row at specified position.

InsertRange(Int32, DataGridViewRow[]) InsertRange(Int32, DataGridViewRow[]) InsertRange(Int32, DataGridViewRow[]) InsertRange(Int32, DataGridViewRow[])

DataGridViewRow 对象插入集合中的指定位置。Inserts the DataGridViewRow objects into the collection at the specified position.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
OnCollectionChanged(CollectionChangeEventArgs) OnCollectionChanged(CollectionChangeEventArgs) OnCollectionChanged(CollectionChangeEventArgs) OnCollectionChanged(CollectionChangeEventArgs)

引发 CollectionChanged 事件。Raises the CollectionChanged event.

Remove(DataGridViewRow) Remove(DataGridViewRow) Remove(DataGridViewRow) Remove(DataGridViewRow)

从集合中删除行。Removes the row from the collection.

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

从集合中删除指定位置的行。Removes the row at the specified position from the collection.

SharedRow(Int32) SharedRow(Int32) SharedRow(Int32) SharedRow(Int32)

返回指定索引处的 DataGridViewRowReturns the DataGridViewRow at the specified index.

ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

事件

CollectionChanged CollectionChanged CollectionChanged CollectionChanged

在该集合的内容发生更改时发生。Occurs when the contents of the collection change.

显式界面实现

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

从指定索引位置开始将集合中的元素复制到 ArrayCopies the elements of the collection to an Array, starting at the specified index.

ICollection.Count ICollection.Count ICollection.Count ICollection.Count

获取集合中包含的元素数。Gets the number of elements contained in the collection.

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

获取一个值,该值指示对集合的访问是否为同步的(线程安全)。Gets a value indicating whether access to the collection is synchronized (thread safe).

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

获取可用于同步对集合的访问的对象。Gets an object that can be used to synchronize access to the collection.

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

返回一个循环访问集合的枚举器。Returns an enumerator that iterates through the collection.

IList.Add(Object) IList.Add(Object) IList.Add(Object) IList.Add(Object)

DataGridViewRow 添加到集合。Adds a DataGridViewRow to the collection.

IList.Clear() IList.Clear() IList.Clear() IList.Clear()

从集合中移除所有项。Removes all items from the collection.

IList.Contains(Object) IList.Contains(Object) IList.Contains(Object) IList.Contains(Object)

确定集合中是否包含指定的项。Determines whether the collection contains the specified item.

IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object)

返回集合中的指定项的索引。Returns the index of a specified item in the collection.

IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object)

DataGridViewRow 插入集合中的指定索引处。Inserts a DataGridViewRow into the collection at the specified index.

IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize

获取一个值,该值指示集合是否具有固定大小。Gets a value indicating whether the collection has a fixed size.

IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly

获取一个值,该值指示集合是否为只读。Gets a value indicating whether the collection is read-only.

IList.Item[Int32] IList.Item[Int32] IList.Item[Int32] IList.Item[Int32]

获取或设置指定索引处的元素。Gets or sets the element at the specified index.

IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) IList.Remove(Object)

从集合中移除指定的 DataGridViewRowRemoves the specified DataGridViewRow from the collection.

IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32)

从集合中删除位于指定位置的 DataGridViewRowRemoves the DataGridViewRow from the collection at the specified position.

扩展方法

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

将转换IEnumerableIQueryableConverts an IEnumerable to an IQueryable.

适用于

另请参阅