Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

SchedulerControl.PopupMenuShowing Event

Occurs before a popup menu is displayed for a SchedulerControl. Allows you to customize the built-in menu or display a custom menu.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v24.2.dll

NuGet Package: DevExpress.Win.Scheduler

#Declaration

public event PopupMenuShowingEventHandler PopupMenuShowing

#Event Data

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

Property Description
Allow Gets or sets whether to enable the popup menu.
HitInfo Gets an object that identifies the menu UI element that the user clicked on.
Menu Gets or sets the popup (context) menu for which this event was raised.
MenuType Gets the type of the popup menu.
Point Gets the position to invoke the popup menu.

#Remarks

Handle the PopupMenuShowing event to do the following:

  • Customize the built-in popup menu (add, remove, and modify menu items).
  • Display a custom popup menu.

Use the e.Menu event parameter to access the built-in popup menu.

The e.MenuType property specifies the type of the popup menu.

Set the e.Allow event parameter to false to prevent the built-in menu from appearing.

#Example: Customize the Popup Menu

This example handles the PopupMenuShowing event to customize the Scheduler’s popup menu (add, modify, and remove existing items):

Customize the Popup Menu - WinForms Scheduler Control, DevExpress

View Example: Customize the Popup Menu

using DevExpress.Utils.Menu;
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Services;
using DevExpress.XtraScheduler.Commands;
// ...
void schedulerControl1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) {
    if (e.MenuType == DevExpress.XtraScheduler.Views.SchedulerMenuType.DefaultMenu) {
        // Hide the "Change View To" menu item
        SchedulerPopupMenu itemChangeViewTo = e.Menu.GetPopupMenuById(SchedulerMenuItemId.SwitchViewMenu);
        itemChangeViewTo.Visible = false;

        // Remove unnecessary items
        e.Menu.RemoveMenuItem(SchedulerMenuItemId.NewAllDayEvent);

        // Disable the "New Recurring Appointment" menu item
        e.Menu.DisableMenuItem(SchedulerMenuItemId.NewRecurringAppointment);

        // Rename the "New Appointment" menu item
        SchedulerMenuItem item = e.Menu.GetMenuItemById(SchedulerMenuItemId.NewAppointment);
        if (item != null) {
            item.Caption = "&New Meeting";
            item.ImageOptions.SvgImage = DevExpress.Utils.Svg.SvgImage.FromFile("NewItem.svg");
        }

        // Display a new menu item for a SchedulerCommand
        ISchedulerCommandFactoryService service = schedulerControl1.GetService<ISchedulerCommandFactoryService>();
        SchedulerCommand cmd = service.CreateCommand(SchedulerCommandId.SwitchToGroupByResource);
        SchedulerMenuItemCommandWinAdapter menuItemCommandAdapter =
            new SchedulerMenuItemCommandWinAdapter(cmd);
        DXMenuItem menuItem = (DXMenuItem)menuItemCommandAdapter.CreateMenuItem(DXMenuItemPriority.Normal);
        menuItem.BeginGroup = true;
        e.Menu.Items.Add(menuItem);

        // Display a new menu item and handle its Click event
        e.Menu.Items.Add(new SchedulerMenuItem("Click me!", MyClickHandler));
    }
}

public void MyClickHandler(object sender, EventArgs e) {
    MessageBox.Show("My menu item was clicked!");
}

#Example: Display a Custom Menu

The following example handles the PopupMenuShowing event to display a custom popup menu when the user right-clicks an appointment. The example sets the e.Allow event parameter to false to prevent the built-in menu from appearing.

Note

In this example, a custom popup menu is created and customized at design time.

void SchedulerControl_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) {
    if(e.MenuType == DevExpress.XtraScheduler.Views.SchedulerMenuType.AppointmentMenu) {
        e.Allow = false;
        customPopupMenu.ShowPopup(Cursor.Position);
    }
}
See Also