Skip to main content

ButtonEdit.ButtonPressed Event

Fires when a user presses a button.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v25.2.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[DXCategory("Events")]
public event ButtonPressedEventHandler ButtonPressed

Event Data

The ButtonPressed event's data class is ButtonPressedEventArgs. The following properties provide information specific to this event:

Property Description
Button Gets the button being pressed/clicked.

Remarks

The editor’s ButtonPressed event is equivalent to the RepositoryItemButtonEdit.ButtonPressed event.

Example

The following code shows a ButtonEdit.ButtonPressed event handler for a button edit control.
When the end-user presses the first button (button with index 0), the handler activates a custom dialog of class Form2. The form’s constructor requires an edit value which will be edited in the dialog. After the form is successfully closed, the modified value is retrieved via the EditingValue property and assigned back to the editor’s edit value.

using DevExpress.XtraEditors.Controls;

private void buttonEdit1_ButtonPressed(object sender, ButtonPressedEventArgs e) {
    ButtonEdit editor = (ButtonEdit)sender;
    int buttonIndex = editor.Properties.Buttons.IndexOf(e.Button);
    if (buttonIndex == 0) {
      using(var form = new Form2(editor.EditValue)) {
          if(form.ShowDialog(this) == DialogResult.OK)
              editor.EditValue = form.EditingValue;
      }
    }
}
See Also