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.v21.1.dll
NuGet Packages: DevExpress.Win.Design, DevExpress.Win.Navigation
Declaration
Related API Members
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.
The following example adds a button to a standalone ButtonEdit control, and handles the ButtonClick event to respond to button clicks.
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 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;
}
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the RepositoryItemButtonEdit class.
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.