Back to Devexpress

SchedulerControl.PrepareContextMenu Event

windowsforms-devexpress-dot-xtrascheduler-dot-schedulercontrol-a6e44659.md

latest5.8 KB
Original Source

SchedulerControl.PrepareContextMenu Event

OBSOLETE

You should use the 'PopupMenuShowing' instead

This member is obsolete. Handle the SchedulerControl.PopupMenuShowing event instead.

Namespace : DevExpress.XtraScheduler

Assembly : DevExpress.XtraScheduler.v25.2.dll

NuGet Package : DevExpress.Win.Scheduler

Declaration

csharp
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("You should use the 'PopupMenuShowing' instead", false)]
public event PrepareContextMenuEventHandler PrepareContextMenu
vb
<Browsable(False)>
<Obsolete("You should use the 'PopupMenuShowing' instead", False)>
<EditorBrowsable(EditorBrowsableState.Never)>
Public Event PrepareContextMenu As PrepareContextMenuEventHandler

Event Data

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

PropertyDescription
AllowGets or sets whether to enable the popup menu. Inherited from PopupMenuShowingEventArgs.
HitInfoGets an object that identifies the menu UI element that the user clicked on. Inherited from PopupMenuShowingEventArgs.
MenuGets or sets the popup (context) menu for which this event was raised. Inherited from PopupMenuShowingEventArgs.
MenuTypeGets the type of the popup menu. Inherited from PopupMenuShowingEventArgs.
PointGets the position to invoke the popup menu. Inherited from PopupMenuShowingEventArgs.

Example

This example demonstrates how to customize the SchedulerControl‘s popup menus (the SchedulerMenuItemId.DefaultMenu in this case). To change particular items in a popup menu handle the SchedulerControl.PopupMenuShowing event of a Scheduler Control.

csharp
using DevExpress.XtraScheduler;
// ...

private void schedulerControl1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)

    // Check if it's the default menu of a Scheduler.
    if (e.Menu.Id == SchedulerMenuItemId.DefaultMenu)
    {

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

        // Hide the "New Recurring Event" menu item.
        e.Menu.RemoveMenuItem(SchedulerMenuItemId.NewRecurringEvent);

        // Enable the "Go To Today" menu item.
        e.Menu.EnableMenuItem(SchedulerMenuItemId.GotoToday);

        // Find the "New Appointment" menu item and rename it.
        SchedulerMenuItem item = e.Menu.GetMenuItemById(SchedulerMenuItemId.NewAppointment);
        if (item != null) item.Caption = "&New Event";
    }
    // Check if it's the appointment menu.
    if(e.Menu.Id == SchedulerMenuItemId.AppointmentMenu) {
      e.Menu.RemoveMenuItem(SchedulerMenuItemId.LabelSubMenu);
      e.Menu.RemoveMenuItem(SchedulerMenuItemId.StatusSubMenu);
    }
}
vb
Imports DevExpress.XtraScheduler
' ...

Private Sub schedulerControl1_PopupMenuShowing(ByVal sender As Object, ByVal e As PopupMenuShowingEventArgs)
    ' Check if it's the default menu of a Scheduler.
    If e.Menu.Id = SchedulerMenuItemId.DefaultMenu Then

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

        ' Hide the "New Recurring Event" menu item.
        e.Menu.RemoveMenuItem(SchedulerMenuItemId.NewRecurringEvent)

        ' Enable the "Go To Today" menu item.
        e.Menu.EnableMenuItem(SchedulerMenuItemId.GotoToday)

        ' Find the "New Appointment" menu item and rename it.
        Dim item As SchedulerMenuItem = e.Menu.GetMenuItemById(SchedulerMenuItemId.NewAppointment)
        If Not item Is Nothing Then
        item.Caption = "&New Event"
        End If
    End If
    ' Check if it's the appointment menu.
    If e.Menu.Id = SchedulerMenuItemId.AppointmentMenu Then
      e.Menu.RemoveMenuItem(SchedulerMenuItemId.LabelSubMenu)
      e.Menu.RemoveMenuItem(SchedulerMenuItemId.StatusSubMenu)
    End If
End Sub

See Also

PopupMenuShowing

SchedulerControl Class

SchedulerControl Members

DevExpress.XtraScheduler Namespace