Back to Devexpress

ButtonEdit() Constructor

windowsforms-devexpress-dot-xtraeditors-dot-buttonedit-dot-ctor-83ffd42b.md

latest4.5 KB
Original Source

ButtonEdit() Constructor

Initializes a new ButtonEdit control instance.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public ButtonEdit()
vb
Public Sub New

Remarks

Use the constructor to create a standalone ButtonEdit control. This initializes all properties to their default values. The editor is created with a single button (of type ButtonPredefines.Ellipsis). The ButtonEdit.Properties property allows you to customize the editor’s appearance and behavior.

To create a button editor inplace for XtraGrid, for instance, you should create a corresponding repository item of the RepositoryItemButtonEdit class and assign it to a column.

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.

csharp
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) {
        //...
    }
}
vb
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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ButtonEdit() constructor.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-custom-buttonedit-display-editvalue-on-button/VB/TestMyButtonEdit/MyButtonEdit.vb#L36

vb
Public Sub New()
    MyBase.New()
End Sub

See Also

RepositoryItemButtonEdit

ButtonEdit Class

ButtonEdit Members

DevExpress.XtraEditors Namespace