Back to Devexpress

SchedulerPopupMenu.GetPopupMenuById(SchedulerMenuItemId) Method

windowsforms-devexpress-dot-xtrascheduler-dot-schedulerpopupmenu-dot-getpopupmenubyid-x28-devexpress-dot-xtrascheduler-dot-schedulermenuitemid-x29.md

latest5.8 KB
Original Source

SchedulerPopupMenu.GetPopupMenuById(SchedulerMenuItemId) Method

Gets a popup menu (menu item which contains a submenu) by its ID value.

Namespace : DevExpress.XtraScheduler

Assembly : DevExpress.XtraScheduler.v25.2.dll

NuGet Package : DevExpress.Win.Scheduler

Declaration

csharp
public SchedulerPopupMenu GetPopupMenuById(
    SchedulerMenuItemId id
)
vb
Public Function GetPopupMenuById(
    id As SchedulerMenuItemId
) As SchedulerPopupMenu

Parameters

NameTypeDescription
idSchedulerMenuItemId

A SchedulerMenuItemId enumeration value which specifies the ID value of the popup menu to search.

|

Returns

TypeDescription
SchedulerPopupMenu

A SchedulerPopupMenu object whose ID is equal to the specified ID value. If a popup menu item with the specified ID isn’t found, then the null ( Nothing in Visual Basic) value will be returned.

|

Remarks

Use the GetPopupMenuById method to find a popup menu item with the specified ID value in the DXSubMenuItem.Items collection of this popup menu, or in any of its submenus. Note that this method finds only the first occurrence of an item with the specified ID.

Example

This example demonstrates how to customize the submenu of the SchedulerControl popup menu. In particular, this sample demonstrates how to find and rename the Label As item of the appointment popup menu and rename the first item of the corresponding submenu.

Call the SchedulerPopupMenu.GetPopupMenuById method to get a popup menu item with the specified ID value and get access to the entire submenu, which is opened with this menu item.

csharp
using DevExpress.XtraScheduler;
// ...

private void schedulerControl1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) {
    if (e.Menu.Id == SchedulerMenuItemId.AppointmentMenu) {
        // Find the "Label As" item of the appointment popup menu and corresponding submenu.
        SchedulerPopupMenu submenu = e.Menu.GetPopupMenuById(SchedulerMenuItemId.LabelSubMenu);
        if (submenu != null) {
            // Rename the item of the appointment popup menu. 
            submenu.Caption = "My Labels";
            // Rename the first item of the submenu.
            submenu.Items[0].Caption = "Label 1";
        }                   
    }
}
vb
Imports DevExpress.XtraScheduler
' ...

Private Sub schedulerControl1_PopupMenuShowing(ByVal sender As Object, _
                                               ByVal e As PopupMenuShowingEventArgs)
            If e.Menu.Id = SchedulerMenuItemId.AppointmentMenu Then
                ' Find the "Label As" item of the appointment popup menu and corresponding submenu.
                Dim submenu As SchedulerPopupMenu = e.Menu.GetPopupMenuById(SchedulerMenuItemId.LabelSubMenu)
                If submenu IsNot Nothing Then
                    ' Rename the item of the appointment popup menu. 
                    submenu.Caption = "My Labels"
                    ' Rename the first item of the submenu.
                    submenu.Items(0).Caption = "Label 1"
                End If
            End If
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetPopupMenuById(SchedulerMenuItemId) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-scheduler-customize-popup-menu/CS/PopupMenuCustomization/Form1.cs#L36

csharp
// Hide the "Change View To" menu item.
SchedulerPopupMenu itemChangeViewTo = e.Menu.GetPopupMenuById(SchedulerMenuItemId.SwitchViewMenu);
itemChangeViewTo.Visible = false;

winforms-scheduler-customize-popup-menu/VB/PopupMenuCustomization/Form1.vb#L31

vb
' Hide the "Change View To" menu item.
Dim itemChangeViewTo As SchedulerPopupMenu = e.Menu.GetPopupMenuById(SchedulerMenuItemId.SwitchViewMenu)
itemChangeViewTo.Visible = False

See Also

GetMenuItemById

SchedulerPopupMenu Class

SchedulerPopupMenu Members

DevExpress.XtraScheduler Namespace