Adds a DataRow to the RowsCollection.
Adds the specified DataRow to the RowsCollection object.
[Visual Basic] Overloads Public Sub Add(DataRow)
[C#] public void Add(DataRow);
[C++] public: void Add(DataRow*);
[JScript] public function Add(DataRow);
Creates a row using specified values and adds it to the RowsCollection.
[Visual Basic] Overloads Overridable Public Function Add(Object()) As DataRow
[C#] public virtual DataRow Add(Object[]);
[C++] public: virtual DataRow* Add(Object*[]);
[JScript] public function Add(Object[]) : DataRow;
The following example uses the Add method to create and add a new DataRow object to a RowsCollection object.
Note This example shows how to use one of the overloaded versions of Add. For other examples that may be available, see the individual overload topics.
[Visual Basic]
' The example presumes a DataTable with three columns. The first ' DataColumn object has its AutoIncrement property set to true ' necessitating that the first value of the array be set to ' System.Object.Empty. Private Sub AddRowByValues() Dim t As DataTable Dim rc As RowsCollection Dim myRow As DataRow Dim rowVals(2) As Object Set t = DataGrid1.DataGridTable.DataTable Set rc = t.Rows rowVals(0) = System.Object.Empty rowVals(1) = "hello" rowVals(2) = "world" Set myRow = rc.Add(rowVals) End Sub
RowsCollection Class | RowsCollection Members | System.Data Namespace