windowsforms-devexpress-dot-xtraeditors-dot-controls-3e6f1c64.md
An editor button displayed in a ButtonEdit control or its descendant.
Namespace : DevExpress.XtraEditors.Controls
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
public class EditorButton :
IDisposable,
ICaptionSupport,
ISupportCommandBinding,
ISupportAppearanceObjectPropertiesFilter
Public Class EditorButton
Implements IDisposable,
ICaptionSupport,
ISupportCommandBinding,
ISupportAppearanceObjectPropertiesFilter
The following members return EditorButton objects:
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.
Edit buttons do not have their own click/press events. Handle the RepositoryItemButtonEdit.ButtonClick and RepositoryItemButtonEdit.ButtonPressed events to respond to button clicks.
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 (EditorButton.ImageOptions.Location).
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");
Imports DevExpress.Utils.Svg
Imports DevExpress.XtraEditors
Imports DevExpress.Utils.Taskbar
Imports DevExpress.XtraEditors.Controls
Private button As EditorButton = 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")
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.
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.
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) {
//...
}
}
Dim btnEdit1 As ButtonEdit = New ButtonEdit()
btnEdit1.Width = 100
btnEdit1.Properties.Buttons(0).Kind = ButtonPredefines.OK
btnEdit1.Properties.Buttons.Add(New EditorButton(ButtonPredefines.Delete))
Panel1.Controls.Add(btnEdit1)
AddHandler btnEdit1.ButtonClick, AddressOf BtnEdit1_ButtonClick
Private Sub BtnEdit1_ButtonClick(sender As Object, e As ButtonPressedEventArgs)
Dim editor As ButtonEdit = TryCast(sender, ButtonEdit)
If e.Button.Kind = ButtonPredefines.OK Then
'...
End If
If e.Button.Kind = ButtonPredefines.Delete Then
'...
End If
End Sub
Object EditorButton CustomHeaderButton
See Also