Skip to main content
A newer version of this page is available. .

EditorButton Class

Represent an individual editor button displayed in a ButtonEdit control or descendant.

Namespace: DevExpress.XtraEditors.Controls

Assembly: DevExpress.XtraEditors.v21.2.dll

NuGet Packages: DevExpress.Win.Design, DevExpress.Win.Navigation

Declaration

public class EditorButton :
    IDisposable,
    ICaptionSupport,
    ISupportCommandBinding

The following members return EditorButton objects:

Remarks

The ButtonEdit editor and all editors derived from it allow you to display an unlimited number of buttons within the editor box. The collection of buttons displayed by an editor is available via the RepositoryItemButtonEdit.Buttons property. This property provides access to a collection object whose members can be used to add, delete and access individual buttons. Each individual button is represented by an EditorButton object. Such objects provide a number of settings specifying the button’s appearance, associated shortcut, visibility, tooltip, etc.

Note: editor buttons do not provide their own events allowing you to handle button clicks. To respond to clicking or pressing an editor button, you should handle the RepositoryItemButtonEdit.ButtonClick and RepositoryItemButtonEdit.ButtonPressed events respectively. These events provide an EditorButton object as the parameter which can be used to identify which button was affected.

Example

The following code creates a ButtonEdit control and places it onto a panel:

The code changes the button collection as follows:

The example subscribes to the ButtonEdit.ButtonClick event to respond to button clicks.

ButtonEdit1_creating_example.gif

ButtonEdit btnEdit1 = new ButtonEdit();
btnEdit1.Width = 100;
btnEdit1.Properties.Buttons[0].Kind = ButtonPredefines.OK;
btnEdit1.Properties.Buttons.Add(new EditorButton(ButtonPredefines.Delete));
panel1.Controls.Add(btnEdit1);

btnEdit1.ButtonClick += BtnEdit1_ButtonClick;

private void BtnEdit1_ButtonClick(object sender, ButtonPressedEventArgs e) {
    ButtonEdit editor = sender as ButtonEdit;
    if(e.Button.Kind == ButtonPredefines.OK) {
        //...
    }
    if (e.Button.Kind == ButtonPredefines.Delete) {
        //...
    }
}

Inheritance

See Also