Represents a collection of rows for a DataTable.
Object
BaseCollection
RowsCollection
[Visual Basic] Public Class RowsCollection Inherits BaseCollection [C#] public class RowsCollection : BaseCollection [C++] public __gc class RowsCollection : public BaseCollection [JScript] public class RowsCollection extends BaseCollection
The RowsCollection is a major component of the DataTable. While the ColumnsCollection defines the schema of the table, the RowsCollection contains the actual data for the table, where each DataRow in the RowsCollection represents a single row.
A RowsCollection object contains all of the DataRow objects for a given DataTable object.
The RowsCollection class uses standard Add and Remove methods, as well as an All method which returns all rows in the collection.
The RowsCollection class also contains the Find method that allow you to search the collection for rows containing specific values. You can also use the Contains method to determine if any row contains specific data.
Namespace: System.Data
Assembly: System.Data.dll
The following example creates a RowsCollection object from a DataTable returned from a System.WinForms.DataGrid control. The code then prints the count of all the elements in the collection as well as columns 1 and 2 of each item in the collection.
[Visual Basic]
Private Sub GetCollectionFromDataGrid() Dim rc As RowsCollection Set rc = DataGrid1.DataGridTable.DataTable.Rows Console.WriteLine(rc.Count) Dim tempRow As DataRow For Each tempRow In rc Console.WriteLine(tempRow.Item(1), tempRow.Item(2)) Next End Sub
RowsCollection Members | System.Data Namespace | DataRow | NewRow