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
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:
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");
}
Related GitHub Examples
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.