Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

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

How to: Respond to Clicking ButtonEdit's Embedded Buttons

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