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.2.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
#Declaration
#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 Delete
Note
Detail pattern Views do not contain data and they are never displayed within Xtra
- Grid
Control. - returns the top most View in a grid;Main View - Grid
Control. - returns the focused View;Focused View - Grid
Control. - returns the currently maximized View;Default View - the sender parameter of View specific events;
- Grid
View. - returns a detail clone View for a specific master row.Get Detail View
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;
}
}