EditorButton Class
An editor button displayed in a ButtonEdit control or its descendant.
Namespace: DevExpress.XtraEditors.Controls
Assembly: DevExpress.XtraEditors.v24.1.dll
NuGet Package: DevExpress.Win.Navigation
#Declaration
public class EditorButton :
IDisposable,
ICaptionSupport,
ISupportCommandBinding,
ISupportAppearanceObjectPropertiesFilter
#Related API Members
The following members return EditorButton objects:
#Remarks
ButtonEdit and all its descendants can display edit buttons within the edit box. The editor stores its buttons within the RepositoryItemButtonEdit.Buttons collection. You can add, remove, and rearrange edit buttons. Button settings allow you to specify the caption, glyph, appearance, shortcut, visibility, tooltip, etc.
#Button Click
Edit buttons do not have their own click/press events. Handle the RepositoryItemButtonEdit.ButtonClick and RepositoryItemButtonEdit.ButtonPressed events to respond to button clicks.
#Button Image and Caption
The Kind property specifies the button’s image. You can choose from over 20 predefined icons or specify a custom image. Set the Kind
property to Glyph
and use the ImageOptions property to display a custom image within the button.
The Caption property specifies the button’s text. The button can display the text together with a custom image only, which is not centered (ImageLocation).
using DevExpress.Utils.Svg;
using DevExpress.XtraEditors;
using DevExpress.Utils.Taskbar;
using DevExpress.XtraEditors.Controls;
EditorButton button = buttonEdit1.Properties.Buttons[0];
button.Caption = "Add Employee";
button.Kind = ButtonPredefines.Glyph;
button.ImageOptions.Location = ImageLocation.MiddleLeft;
button.ImageOptions.SvgImage = SvgImage.FromFile("custom-image.svg");
#Wrap Button Caption
The Button Editor stretches its edit buttons if the TextEditStyle property is set to TextEditStyles.HideTextEditor
. Disable the Button Editor’s Properties.AutoHeight option, specify the height, and set the button’s Appearance.TextOptions.WordWrap property to Wrap
to break the long text and wrap it onto the next line.
#Example
The following code creates a ButtonEdit control and places it onto a panel:
The code changes the button collection as follows:
- Changes the default button glyph (ellipsis) into (ButtonPredefines.OK).
- Adds a button that displays the glyph (ButtonPredefines.Delete).
The example subscribes to the ButtonEdit.ButtonClick event to respond to button clicks.
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) {
//...
}
}