MultiRow Windows Forms > Developer's Guide > Using MultiRow > Rows and Cells > Adding Rows |
The user can add rows using the row editor displayed in the bottom row of the GcMultiRow control when the AllowUserToAddRows property is set to True. The following image displays the row editor.
This example sets the AllowUserToAddRows property.
GcMultiRow1.AllowUserToAddRows = True |
gcMultiRow1.AllowUserToAddRows = true; |
If the GcMultiRow.AllowUserToAddRows property is set to False, the row editor is not displayed at the bottom of the GcMultiRow control and the user cannot add rows.
This example sets the AllowUserToAddRows property to false.
GcMultiRow1.AllowUserToAddRows = False |
gcMultiRow1.AllowUserToAddRows = false; |
You can add a row using the RowCollection.Insert method or the RowCollection.Add method.
This example uses the Add method.
GcMultiRow1.Rows.Add() |
gcMultiRow1.Rows.Add(); |
You cannot add rows using the RowCollection.Add method when the GcMultiRow control is bound to a data source. If the control is bound to a data source, add rows in the data source (for example, use the BindingSource.AddNew method or DataTable.Rows.Add method).
You can change the row count of the GcMultiRow control to add additional rows to the control.
This example increases the row count.
GcMultiRow1.RowCount += 1 |
gcMultiRow1.RowCount += 1; |
You cannot change the row count using the GcMultiRow.RowCount property when the GcMultiRow control is bound to a data source. If the control is bound to a data source, change the row count (record count) in the data source.
When the GcMultiRow control is bound to the data source, you can add rows to the GcMultiRow control though the data source by setting both IBindingList.AllowNew properties to true.
The GcMultiRow.RowsAdding event occurs when you add a row to the GcMultiRow control. After the row is added, the GcMultiRow.RowsAdded event occurs. The GcMultiRow.UserAddedRow event occurs when the user adds a row using the Row Editor.