How to: Perform Custom Actions when End-Users Click Navigator Buttons

The following sample code handles the NavigatorBase.ButtonClick event to confirm with the user before deleting a record. A warning message box is shown each time a user presses the Remove button. The user can then click the Yes button to remove the current record or alternatively the No button to cancel deletion of the record.

using DevExpress.XtraEditors;

private void dataNavigator1_ButtonClick(object sender, NavigatorButtonClickEventArgs e) {
    if (e.Button.ButtonType == NavigatorButtonType.Remove)
        if (MessageBox.Show("Do you really want to delete the record?", "Warning", 
          MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
            e.Handled = true;