Skip to main content

RepositoryItemButtonEdit Class

An object that contains settings specific to a ButtonEdit control. Repository items allow you to embed editors into container controls (for instance, GridControl, TreeList, RibbonControl).

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public class RepositoryItemButtonEdit :
    RepositoryItemTextEdit

The following members return RepositoryItemButtonEdit objects:

Remarks

A RepositoryItemButtonEdit object contains properties, methods, and events related to a ButtonEdit control.

Standalone Editors

If you use a standalone ButtonEdit control, its ButtonEdit.Properties property returns a RepositoryItemButtonEdit instance. You can access this object to customize the editor’s settings.

RepositoryItemButtonEdit

The following example adds a button to a standalone ButtonEdit control, and handles the ButtonClick event to respond to button clicks.

ButtonEdit-example

using DevExpress.XtraEditors.Repository;

RepositoryItemButtonEdit properties = buttonEdit1.Properties;
properties.Buttons.Clear();
properties.Buttons.Add(new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Close));
properties.ButtonClick += Properties_ButtonClick;

private void Properties_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) {
    if(e.Button.Kind==DevExpress.XtraEditors.Controls.ButtonPredefines.Close) {
        //...
    }
}

In-place Editors

For each editor that can be embedded in a composite control (for instance, GridControl, TreeList, RibbonControl) the DevExpress Editors library has a corresponding repository item (a RepositoryItem descendant).

Create a RepositoryItemButtonEdit object to embed a ButtonEdit control into such a composite control. See the following topic for more information: Editors and Simple Controls.

Example - Create Inplace Editor

The following example embeds an in-place ButtonEdit editor (a RepositoryItemButtonEdit object) into a Data Grid’s “Description” column.

The example creates two buttons (Undo and Copy) for the editor and handles the RepositoryItemButtonEdit.ButtonClick event to perform actions when a user clicks any of these buttons.

RepositoryItemButtonEdit example

RepositoryItemButtonEdit inplaceButtonEdit = new RepositoryItemButtonEdit();
inplaceButtonEdit.Buttons.Clear();
//Undo Button
EditorButton undoButton = new EditorButton(ButtonPredefines.Undo);
undoButton.Enabled = false;
//Copy Button
EditorButton copyButton = new EditorButton(ButtonPredefines.Glyph);
copyButton.Caption = "Copy";
copyButton.ImageOptions.SvgImage = global::WindowsFormsApplication2.Properties.Resources.copy;
copyButton.ImageOptions.SvgImageSize = new Size(16, 16);

inplaceButtonEdit.Buttons.Add(undoButton);
inplaceButtonEdit.Buttons.Add(copyButton);
inplaceButtonEdit.ButtonClick += InplaceButtonEdit_ButtonClick;
inplaceButtonEdit.EditValueChanged += InplaceButtonEdit_EditValueChanged;
gridView1.Columns["Description"].ColumnEdit = inplaceButtonEdit;
gridView1.GridControl.RepositoryItems.Add(inplaceButtonEdit);


private void InplaceButtonEdit_ButtonClick(object sender, ButtonPressedEventArgs e) {
    ButtonEdit editor = sender as ButtonEdit;
    if (e.Button.Kind == ButtonPredefines.Undo) {
        editor.Undo();
    }
    if (e.Button.Kind == ButtonPredefines.Glyph && e.Button.Caption == "Copy") {
        editor.SelectAll();
        editor.Copy();
    }
}

private void InplaceButtonEdit_EditValueChanged(object sender, EventArgs e) {
    ButtonEdit editor = sender as ButtonEdit;
    if (editor.Properties.Buttons.Count == 0) return;
    EditorButton undoButton = editor.Properties.Buttons[0];
    if ( undoButton.Kind == ButtonPredefines.Undo) {
        undoButton.Enabled = editor.CanUndo;
    }
}
See Also