Skip to main content

ColumnView.DeleteSelectedRows() Method

Deletes the selected rows/cards in multiple selection mode or focused row/card in single selection mode.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v24.1.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

public virtual void DeleteSelectedRows()

Remarks

In single row selection mode, this method deletes the focused row. In multiple row selection mode this method deletes the selected rows. In multiple cell selection mode this method deletes the rows to which selected cells belong.

The current selection mode is determined by the ColumnViewOptionsSelection.MultiSelect and GridOptionsSelection.MultiSelectMode options.

For Grid Views and their descendants the DeleteSelectedRows method affects both the selected data rows and group rows. In Card Views, this method deletes the selected cards. To get references to the selected rows, use the ColumnView.GetSelectedRows method. To get selected cells (in multiple cell selection mode) use the GridView.GetSelectedCells method.

To delete a specific row use the ColumnView.DeleteRow method.

Note

If the DeleteSelectedRows method is called for a master row, only this row is removed. The detail clone view’s records remain untouched.

Note

Detail pattern Views do not contain data and they are never displayed within XtraGrid. So, the DeleteSelectedRows member must not be invoked for these Views. The DeleteSelectedRows member can only be used with Views that display real data within the Grid Control. Use the following methods to access these Views with which an end user interacts at runtime.

The code sample below illustrates how to delete the selected row(s) when a user presses Delete.

gridControl1.ProcessGridKey += GridControl1_ProcessGridKey;

private void GridControl1_ProcessGridKey(object sender, KeyEventArgs e)
{
    var grid = sender as GridControl;
    var view = grid.FocusedView as GridView;
    if (e.KeyData == Keys.Delete)
    {
        view.DeleteSelectedRows();
        e.Handled = true;
    }
}
See Also