RepositoryItemButtonEdit.ButtonClick Event

Occurs when an editor button is clicked.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v20.1.dll

Declaration

[DXCategory("Events")]
public event ButtonPressedEventHandler ButtonClick
<DXCategory("Events")>
Public Event ButtonClick As ButtonPressedEventHandler

Event Data

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.

Remarks

Write a ButtonClick event handler to implement additional functionality when a user clicks an editor button. You can, for instance, activate a custom dropdown window, a dialog, or perform specific calculations based on entered values, etc.

The ButtonClick event occurs when the user releases the pressed button. When the button is pressed and not yet released, the RepositoryItemButtonEdit.ButtonPressed event is fired. When the user presses a button and moves the mouse pointer to another control, then the ButtonClick event does not occur.

The sender parameter of an event handler represents the button edit control whose button is clicked. The button itself is identified by another event parameter (see the ButtonPressedEventArgs.Button property).

The ButtonClick event is also fired when the user edits the control's text and presses a shortcut assigned to one of editor buttons. In this case, the ButtonPressedEventArgs.Button parameter identifies the button whose shortcut was pressed. If several buttons are assigned the same shortcut, the ButtonClick event occurs in turn for every such button.

For a popup editor, the ButtonClick event does not fire when the popup is open and an end-user clicks the dropdown button.

The editor's ButtonEdit.ButtonClick event is equivalent to the current event.

Examples

This example assumes that a form contains a ButtonEdit control with two buttons.

The following code shows how to respond to clicking these buttons via the ButtonEdit.ButtonClick event.

The result of clicking the second button for a button edit control is displayed below:

ButtonEdit1_ButtonClick

using DevExpress.XtraEditors.Controls;

private void buttonEdit1_ButtonClick(object sender, ButtonPressedEventArgs e) {
    ButtonEdit editor = (ButtonEdit)sender;
    EditorButton Button = e.Button;
    string Info = "";
    string EOL = "\n";
    Info += " Kind: " + Button.Kind.ToString() + EOL;
    Info += " Caption: " + Button.Caption + EOL;
    Info += " Image assigned: " + (Button.Image != null).ToString() + EOL;
    Info += " Shortcut: " + Button.Shortcut.ToString() + EOL;
    Info += " IsLeft: " + Button.IsLeft.ToString() + EOL;
    Info += " Width: " + Button.Width.ToString() + EOL;
    Info += " Index: " + editor.Properties.Buttons.IndexOf(e.Button).ToString();

    XtraMessageBox.Show(Info, "ButtonClick event");
}
See Also