Skip to main content

EditorButton(ButtonPredefines, String, Int32, Boolean, Boolean, Boolean, HorzAlignment, Image, KeyShortcut) Constructor

Initializes a new EditorButton instance with the specified property values.

Namespace: DevExpress.XtraEditors.Controls

Assembly: DevExpress.XtraEditors.v25.2.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[EditorBrowsable(EditorBrowsableState.Never)]
public EditorButton(
    ButtonPredefines kind,
    string caption,
    int width,
    bool enabled,
    bool visible,
    bool isLeft,
    HorzAlignment imageAlignment,
    Image image,
    KeyShortcut shortcut
)

Parameters

Name Type Description
kind ButtonPredefines

The value to initialize the button’s EditorButton.Kind property.

caption String

A String value which specifies the button’s caption. This value is assigned to the EditorButton.Caption property.

width Int32

An integer value specifying the button’s width. This value is assigned to the EditorButton.Width property.

enabled Boolean

The value to initialize the button’s EditorButton.Enabled property.

visible Boolean

The value to initialize the button’s EditorButton.Visible property.

isLeft Boolean

The value to initialize the button’s EditorButton.IsLeft property.

imageAlignment HorzAlignment

The value to initialize the button’s ImageLocation property.

image Image

The value to initialize the button’s Image property.

shortcut KeyShortcut

The value to initialize the button’s EditorButton.Shortcut property.

Remarks

The constructor allows you to create a button with the specified property values. After the button is created, you can add it to the button collection of a ButtonEdit control. For this purpose, use the EditorButtonCollection.Add method accessible via the RepositoryItemButtonEdit.Buttons property.

Example

The following code snippet creates a ButtonEdit control, customizes its buttons, and places the editor onto the form:

using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;

namespace DXApplication {
    public partial class Form1 : XtraForm {
        public Form1() {
            InitializeComponent();

            // Create a `ButtonEdit` and add it to the form.
            ButtonEdit btnEdit1 = new ButtonEdit() {
                Width = 200
            };

            // Configure the default (first) button as an OK button.
            btnEdit1.Properties.Buttons[0].Kind = ButtonPredefines.OK;

            // Add an additional button and treat it as a Delete action.
            btnEdit1.Properties.Buttons.Add(new EditorButton(ButtonPredefines.Delete));

            // Add the editor to the form's controls collection.
            this.Controls.Add(btnEdit1);

            // Handle button clicks.
            btnEdit1.ButtonClick += BtnEdit1_ButtonClick;
        }
        void BtnEdit1_ButtonClick(object sender, ButtonPressedEventArgs e) {
            ButtonEdit editor = sender as ButtonEdit;
            if (e.Button.Kind == ButtonPredefines.OK) {
                // OK button pressed.
                //...
            }
            if (e.Button.Kind == ButtonPredefines.Delete) {
                // Delete button pressed.
                //...
            }
        }
    }
}
See Also