Skip to main content

DevExpress v24.1 Update — Your Feedback Matters

Our What's New in v24.1 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

ButtonEdit.ButtonClick Event

Occurs when a button editor’s button is clicked.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

#Declaration

[DXCategory("Events")]
public event ButtonPressedEventHandler ButtonClick

#Event Data

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

Property Description
Button Gets the button being pressed/clicked.

#Remarks

Use this event to perform actions when a user clicks an editor button. You can, for instance, activate a custom dropdown window, a dialog or perform calculations based on a value entered etc.

The editor’s ButtonClick event is equivalent to the RepositoryItemButtonEdit.ButtonClick event available via the ButtonEdit.Properties object, i.e. adding/removing an event handler for the current event actually affects the RepositoryItemButtonEdit.ButtonClick event.

Refer to the RepositoryItemButtonEdit.ButtonClick topic for more information.

#Example

This example assumes that a form contains a ButtonEdit control with two buttons.

The following code shows how to respond to clicking these buttons via the ButtonEdit.ButtonClick event.

The result of clicking the second button for a button edit control is displayed below:

ButtonEdit1_ButtonClick

using DevExpress.XtraEditors.Controls;

private void buttonEdit1_ButtonClick(object sender, ButtonPressedEventArgs e) {
    ButtonEdit editor = (ButtonEdit)sender;
    EditorButton Button = e.Button;
    string Info = "";
    string EOL = "\n";
    Info += " Kind: " + Button.Kind.ToString() + EOL;
    Info += " Caption: " + Button.Caption + EOL;
    Info += " Image assigned: " + (Button.Image != null).ToString() + EOL;
    Info += " Shortcut: " + Button.Shortcut.ToString() + EOL;
    Info += " IsLeft: " + Button.IsLeft.ToString() + EOL;
    Info += " Width: " + Button.Width.ToString() + EOL;
    Info += " Index: " + editor.Properties.Buttons.IndexOf(e.Button).ToString();

    XtraMessageBox.Show(Info, "ButtonClick event");
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference 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.

See Also