GrapeCity MultiRow Windows Forms Documentation
Deleting Rows

You can delete rows in GcMultiRow.

Users Deleting Rows

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.

Using Code

This example sets the AllowUserToDeleteRows property.

[VB]

GcMultiRow1.AllowUserToDeleteRows = True

[CS]

gcMultiRow1.AllowUserToDeleteRows = true;

Deleting Rows Using Code

You can delete a row using the RowCollection.Remove method.

Using Code

The following code deletes the current row.

[VB]

GcMultiRow1.Rows.RemoveAt(GcMultiRow1.CurrentRow.Index)

[CS]

gcMultiRow1.Rows.RemoveAt(gcMultiRow1.CurrentRow.Index);

An exception is thrown if the index of a non-existent row is specified.

Deleting Rows Using Row Count

You can delete rows by decreasing the value of the RowCount property of the GcMultiRow control.

Using Code

This example decreases the row count.

[VB]

GcMultiRow1.RowCount -= 1

[CS]

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.

Deleting Rows in 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.

Deleting All Rows

Call the RowCollection.Clear method to delete all the rows.

Using Code

This example uses the Clear method.

[VB]

GcMultiRow1.Rows.Clear()

[CS]

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.

Events for Deleting Rows

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.

See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options