Skip to main content

ButtonEdit.ButtonClick Event

Fires when a user clicks a button.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v25.2.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

Handle the ButtonClick event to perform actions when a user clicks a button. For example, open a custom drop-down window, a dialog, or perform calculations based on the edit value.

The ButtonClick event is equivalent to the RepositoryItemButtonEdit.ButtonClick event.

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