RepositoryItemButtonEdit.ButtonClick Event
Occurs when an editor button is clicked.
Namespace: DevExpress.XtraEditors.Repository
Assembly: DevExpress.XtraEditors.v24.2.dll
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
Handle the ButtonClick
event to implement additional functionality when a user clicks an editor button. For example, you can activate a custom drop-down window or dialog, or perform calculations based on entered values.
The ButtonEdit.ButtonClick event is equivalent to the RepositoryItemButtonEdit.ButtonClick
event.
ButtonClick
fires when:
- A user releases the pressed button.
- A user edits the text in the edit box and presses shortcut key(s) assigned to an editor button.
ButtonClick
does not fire when:
- The button is pressed and is not yet released (the RepositoryItemButtonEdit.ButtonPressed event fires).
- A user presses a button and moves the mouse pointer to another control.
- A popup editor’s popup is open and a user clicks the drop-down button.
The sender
parameter of an event handler is the button edit control that contains the clicked button. Use the e.Button parameter to identify the clicked button. If a user presses shortcut key(s) and several buttons are assigned the same shortcut, the ButtonClick
event occurs for all such buttons.
Example
In this example, the form contains a ButtonEdit control added at design time.
The following code snippet adds buttons to the ButtonEdit
and handles the ButtonClick
event to respond to clicks on these buttons.
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
namespace DXApplication6 {
public partial class Form1 : DevExpress.XtraEditors.XtraForm {
public Form1() {
InitializeComponent();
buttonEdit1.Properties.Buttons.Add(new EditorButton("message", ButtonPredefines.Ellipsis));
buttonEdit1.Properties.Buttons.Add(new EditorButton("message", ButtonPredefines.Search));
buttonEdit1.Properties.Buttons.Add(new EditorButton(ButtonPredefines.Clear));
buttonEdit1.ButtonClick += ButtonEdit1_ButtonClick;
}
private void ButtonEdit1_ButtonClick(object sender, ButtonPressedEventArgs e) {
if (e.Button.Tag?.ToString() == "message")
XtraMessageBox.Show($"{e.Button.Kind} button clicked.", "Information");
if (e.Button.Kind == ButtonPredefines.Clear)
((ButtonEdit)sender).Clear();
}
}
}
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.