AccordionControl.ElementClick Event
Fires when a group or item is clicked.
Namespace: DevExpress.XtraBars.Navigation
Assembly: DevExpress.XtraBars.v24.2.dll
Declaration
Event Data
The ElementClick event's data class is DevExpress.XtraBars.Navigation.ElementClickEventArgs.
Remarks
The ElementClick
event fires when any group or item in the control is clicked. Use the Element event argument to get the clicked element. The MouseButton argument returns the clicked mouse button. The event also fires if an element is focused and the user presses the Enter or Space key.
The AccordionControlElementBase.Click event allows you to assign an event handler to a particular element. The ElementClick
event fires after the Click event.
Examples
The code below shows how to prevent an item from being selected and show a pop-up form with a right-click.
using DevExpress.XtraBars.Navigation;
accordionControl1.AllowItemSelection = true;
private void accordionControl1_ElementClick(object sender, ElementClickEventArgs e) {
if (e.MouseButton == MouseButtons.Right || e.Element.Style == ElementStyle.Group) {
popupMenu1.ShowPopup(Control.MousePosition);
e.Handled = true;
}
}
The code below shows how to close the pop-up form when the user clicks an item.
using DevExpress.XtraBars.Navigation;
accordionControl1.OptionsHamburgerMenu.DisplayMode = AccordionControlDisplayMode.Inline;
accordionControl1.ViewType = AccordionControlViewType.HamburgerMenu;
private void accordionControl1_ElementClick(object sender, DevExpress.XtraBars.Navigation.ElementClickEventArgs e) {
AccordionControl accordionControl = sender as AccordionControl;
if (e.MouseButton == MouseButtons.Left && accordionControl.IsPopupFormShown) {
accordionControl.ClosePopupForm();
e.Handled = true;
}
}
The code below shows how handle the ElementClick
event to prevent a particular group from being expanded with a right-click and show a pop-up menu instead. The example assumes that you placed a PopupMenu object on the component tray in the designer.
using DevExpress.XtraBars.Navigation;
private void accordionControl1_ElementClick(object sender, ElementClickEventArgs e) {
AccordionControl accordionControl = sender as AccordionControl;
if (e.MouseButton == MouseButtons.Right && e.Element.Style == ElementStyle.Group && e.Element == accordionControlElement1) {
popupMenu1.ShowPopup(Control.MousePosition);
e.Handled = true;
}
}