NavigatorBase.ButtonClick Event

Enables you to perform custom actions when end-users click navigator buttons.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v20.1.dll

Declaration

[DXCategory("Events")]
public event NavigatorButtonClickEventHandler ButtonClick
<DXCategory("Events")>
Public Event ButtonClick As NavigatorButtonClickEventHandler

Event Data

The ButtonClick event's data class is NavigatorButtonClickEventArgs. The following properties provide information specific to this event:

Property Description
Button Gets the clicked button.
Handled Gets or sets whether you have handled this event and no default action is required.

Remarks

Each button has its default action. For example, the First button's default behavior is to set the current record to the first record in a data source. This default action is performed each time a user clicks the button. You can however, override the default behavior or perform additional actions when buttons are clicked. Handle the ButtonClick event for this purpose. This event fires each time a navigator button is clicked.

The event's Button parameter allows you to identify the clicked button. If you want to perform the button's default action after your event handler is executed, set the event's Handled parameter to false. To prevent this action from being performed, set the Handled parameter to true.

Examples

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