windowsforms-devexpress-dot-xtraeditors-dot-repository-dot-repositoryitembuttonedit-ed843a7f.md
Occurs when an editor button is clicked.
Namespace : DevExpress.XtraEditors.Repository
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DXCategory("Events")]
public event ButtonPressedEventHandler ButtonClick
<DXCategory("Events")>
Public Event ButtonClick As ButtonPressedEventHandler
The ButtonClick event's data class is ButtonPressedEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Button | Gets the button being pressed/clicked. |
Handle the ButtonClick event to implement additional functionality when a user clicks an editor button. For example, you can activate a custom drop-down window or dialog, or perform calculations based on entered values.
The ButtonEdit.ButtonClick event is equivalent to the RepositoryItemButtonEdit.ButtonClick event.
ButtonClick fires when:
ButtonClick does not fire when:
The sender parameter of an event handler is the button edit control that contains the clicked button. Use the e.Button parameter to identify the clicked button. If a user presses shortcut key(s) and several buttons are assigned the same shortcut, the ButtonClick event occurs for all such buttons.
In this example, the form contains a ButtonEdit control added at design time.
The following code snippet adds buttons to the ButtonEdit and handles the ButtonClick event to respond to clicks on these buttons.
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
namespace DXApplication6 {
public partial class Form1 : DevExpress.XtraEditors.XtraForm {
public Form1() {
InitializeComponent();
buttonEdit1.Properties.Buttons.Add(new EditorButton("message", ButtonPredefines.Ellipsis));
buttonEdit1.Properties.Buttons.Add(new EditorButton("message", ButtonPredefines.Search));
buttonEdit1.Properties.Buttons.Add(new EditorButton(ButtonPredefines.Clear));
buttonEdit1.ButtonClick += ButtonEdit1_ButtonClick;
}
private void ButtonEdit1_ButtonClick(object sender, ButtonPressedEventArgs e) {
if (e.Button.Tag?.ToString() == "message")
XtraMessageBox.Show($"{e.Button.Kind} button clicked.", "Information");
if (e.Button.Kind == ButtonPredefines.Clear)
((ButtonEdit)sender).Clear();
}
}
}
Imports DevExpress.XtraEditors
Imports DevExpress.XtraEditors.Controls
Namespace DXApplication6
Partial Public Class Form1
Inherits DevExpress.XtraEditors.XtraForm
Public Sub New()
InitializeComponent()
buttonEdit1.Properties.Buttons.Add(New EditorButton("message", ButtonPredefines.Ellipsis))
buttonEdit1.Properties.Buttons.Add(New EditorButton("message", ButtonPredefines.Search))
buttonEdit1.Properties.Buttons.Add(New EditorButton(ButtonPredefines.Clear))
AddHandler buttonEdit1.ButtonClick, AddressOf ButtonEdit1_ButtonClick
End Sub
Private Sub ButtonEdit1_ButtonClick(ByVal sender As Object, ByVal e As ButtonPressedEventArgs)
If e.Button.Tag?.ToString() = "message" Then
XtraMessageBox.Show($"{e.Button.Kind} button clicked.", "Information")
End If
If e.Button.Kind = ButtonPredefines.Clear Then
DirectCast(sender, ButtonEdit).Clear()
End If
End Sub
End Class
End Namespace
The following code snippets (auto-collected from DevExpress Examples) contain references to the ButtonClick event.
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.
((RepositoryItemLookupEdit)item).Buttons.Add(new EditorButton(ButtonPredefines.Glyph, "Edit", -1, true, true, true, HorzAlignment.Default, null, new KeyShortcut(System.Windows.Forms.Keys.Enter), appearance, "Press this button to edit the object"));
((RepositoryItemLookupEdit)item).ButtonClick += new ButtonPressedEventHandler(MyLookupPropertyEditor_ButtonClick);
}
winforms-property-grid-create-custom-editor/CS/T415077/Form1.cs#L20
RepositoryItemButtonEdit edit = new RepositoryItemButtonEdit();
edit.ButtonClick += edit_ButtonClick;
(this.propertyGridControl1.Rows[0] as CategoryRow).ChildRows["rowPath2"].Properties.RowEdit = edit;
winforms-pdf-viewer-operate-pdf-content-at-runtime/CS/WindowsFormsApplication1/MainForm.cs#L19
pdfViewer1.LoadDocument(@"..\..\TextExtraction.pdf");
repositoryItemButtonEdit3.ButtonClick += repositoryItemButtonEdit3_ButtonClick;
}
buttonEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
buttonEdit.ButtonClick += ButtonEdit_ButtonClick;
urlBarItem = new BarEditItem(designer.Ribbon.Manager, buttonEdit);
winforms-property-grid-create-custom-editor/VB/T415077/Form1.vb#L26
Dim edit As RepositoryItemButtonEdit = New RepositoryItemButtonEdit()
AddHandler edit.ButtonClick, AddressOf edit_ButtonClick
TryCast(propertyGridControl1.Rows(0), CategoryRow).ChildRows("rowPath2").Properties.RowEdit = edit
winforms-pdf-viewer-operate-pdf-content-at-runtime/VB/WindowsFormsApplication1/MainForm.vb#L21
pdfViewer1.LoadDocument("..\..\TextExtraction.pdf")
AddHandler repositoryItemButtonEdit3.ButtonClick, AddressOf repositoryItemButtonEdit3_ButtonClick
End Sub
buttonEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor
AddHandler buttonEdit.ButtonClick, AddressOf ButtonEdit_ButtonClick
urlBarItem = New BarEditItem(designer.Ribbon.Manager, buttonEdit)
See Also
RepositoryItemButtonEdit Class