NavigatorBase.ButtonClick Event
Enables you to perform custom actions when end-users click navigator buttons.
Namespace: DevExpress.XtraEditors
Assembly: DevExpress.XtraEditors.v24.1.dll
NuGet Package: DevExpress.Win.Navigation
Declaration
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.
Example
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;
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the ButtonClick event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.