MultiRow Windows Forms > Developer's Guide > Using MultiRow > Rows and Cells > Deleting Rows |
You can delete rows in GcMultiRow.
The user can delete the current row by pressing the Ctrl + Delete keys if the GcMultiRow.AllowUserToDeleteRows property is set to True. This shortcut key is defined in GcMultiRow.ShortcutKeyManager.
This example sets the AllowUserToDeleteRows property.
GcMultiRow1.AllowUserToDeleteRows = True |
gcMultiRow1.AllowUserToDeleteRows = true; |
You can delete a row using the RowCollection.Remove method.
The following code deletes the current row.
GcMultiRow1.Rows.RemoveAt(GcMultiRow1.CurrentRow.Index) |
gcMultiRow1.Rows.RemoveAt(gcMultiRow1.CurrentRow.Index); |
An exception is thrown if the index of a non-existent row is specified.
You can delete rows by decreasing the value of the RowCount property of the GcMultiRow control.
This example decreases 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, modify the row count (number of records) of the data source.
When the GcMultiRow control is bound to a data source, you can delete rows from the control through the data source if both the IBindingList.AllowRemove properties of the data source are set to True.
Call the RowCollection.Clear method to delete all the rows.
This example uses the Clear method.
GcMultiRow1.Rows.Clear() |
gcMultiRow1.Rows.Clear(); |
Note that a new row is always displayed when the GcMultiRow.AllowUserToAddRows property is set to True. To make the row count zero, set the property to False.
The GcMultiRow.RowsRemoving event occurs when you delete rows from the GcMultiRow control. After the rows have been deleted, the GcMultiRow.RowsRemoved event occurs. When a user deletes rows using the Ctrl + Delete keys, the GcMultiRow.UserDeletingRow and GcMultiRow.UserDeletedRow events occur.