Skip to main content

SchedulerControl.PopupMenuShowing Event

Occurs before a popup menu is displayed for a SchedulerControl. Allows you to customize menu items.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v24.1.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 change specific items in the popup menu every time it is displayed. The popup menu is accessible with the Menu event parameter.

The SchedulerMenuItemId enumeration lists all popup menu types.

To retrieve the right-clicked appointment (or the appointment group), access the SchedulerControl.SelectedAppointments collection.

This example demonstrates how to customize the SchedulerControl‘s popup menus (the SchedulerMenuItemId.DefaultMenu in this case). To add, remove or modify items in a popup menu, handle the SchedulerControl.PopupMenuShowing event of a Scheduler Control, and then use the PopupMenuShowingEventArgs.Menu property.

View Example

using DevExpress.Utils.Menu;
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Services;
using DevExpress.XtraScheduler.Commands;
// ...
private void schedulerControl1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
{
    if (e.Menu.Id == DevExpress.XtraScheduler.SchedulerMenuItemId.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);

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

        // Create a menu item for the Scheduler command.
        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);

        // Insert a new item into the Scheduler popup menu 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 Clicked!");
}
See Also