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.v24.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 | Button |
The value to initialize the button’s Editor |
caption | String | A String value which specifies the button’s caption. This value is assigned to the Editor |
width | Int32 | An integer value specifying the button’s width. This value is assigned to the Editor |
enabled | Boolean | The value to initialize the button’s Editor |
visible | Boolean | The value to initialize the button’s Editor |
is |
Boolean | The value to initialize the button’s Editor |
image |
Horz |
The value to initialize the button’s |
image | Image | The value to initialize the button’s |
shortcut | Key |
The value to initialize the button’s Editor |
#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 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) {
//...
}
}