Skip to main content

ButtonEdit.ButtonClick Event

Occurs when a button editor’s button is clicked.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v24.2.dll

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

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

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