Skip to main content

How to: Respond to Clicking ButtonEdit's Embedded Buttons

  • 2 minutes to read

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:

ButtonEdit1_ButtonClick

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