Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Delete a Row When the CTRL+DEL Shortcut is Pressed

The following code deletes the focused row when the end-user presses the Ctrl+Del shortcut.

To process key press events, we handle the BaseView.KeyDown event. The row is deleted by calling the ColumnView.DeleteRow method.

private void gridView1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) {
    if (e.KeyCode == Keys.Delete && e.Modifiers == Keys.Control) {
        if (MessageBox.Show("Delete row?", "Confirmation", MessageBoxButtons.YesNo) != 
          DialogResult.Yes)
            return;
        GridView view = sender as GridView;                
        view.DeleteRow(view.FocusedRowHandle);
    }
}
See Also