Skip to main content
A newer version of this page is available. .

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.v19.1.dll

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 real Views that are displayed within the Grid Control. The real Views with which an end-user interacts at runtime can be accessed using the following methods.

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;
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the DeleteSelectedRows() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also