Back to Devexpress

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

windowsforms-9499-controls-and-libraries-editors-and-simple-controls-examples-how-to-perform-custom-actions-when-end-users-click-navigator-buttons.md

latest1.4 KB
Original Source

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

  • Oct 25, 2019

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.

csharp
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;
}
vb
Imports DevExpress.XtraEditors

Private Sub DataNavigator1_ButtonClick(ByVal sender As Object, _
  ByVal e As DevExpress.XtraEditors.NavigatorButtonClickEventArgs) _
  Handles DataNavigator1.ButtonClick
    If e.Button.ButtonType = NavigatorButtonType.Remove Then
        If MessageBox.Show("Do you really want to delete the record?", "Warning", _
          MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.No Then
            e.Handled = True
        End If
    End If
End Sub