Schedule / Commanding / Context Menu
In This Topic
Context Menu
In This Topic

NOV Schedule lets you fully customize the context menu shown when the user right clicks somewhere in the schedule view. To do so, you should create a class that inherits NScheduleContextMenu and override the methods you are interested in. Most commonly you will need to override one or both of the following methods:

The code example below demonstrates how to create a schedule context menu factory that adds a custom command at the bottom of the context menu:

Create custom schedule context menu
Copy Code
public class CustomContextMenu : NScheduleContextMenu
{
    public CustomContextMenu()
    {
    }
    static CustomContextMenu()
    {
        CustomContextMenuSchema = NSchema.Create(typeof(CustomContextMenu), NScheduleContextMenu.NScheduleContextMenuSchema);
    }

    protected override void CreateCustomCommands(NMenu menu)
    {
        base.CreateCustomCommands(menu);

        // Create a context menu builder
        NContextMenuBuilder builder = new NContextMenuBuilder();

        // Add a custom command
        builder.AddMenuItem(menu, NResources.Image_Ribbon_16x16_smiley_png, CustomCommand);
    }

    public static readonly NSchema CustomContextMenuSchema;
}

When you've created your custom schedule context menu factory, you should create an instance of it and assign it to the ContextMenu property of the schedule view:

Assign a schedule context menu factory to a schedule view
Copy Code
scheduleView.ContextMenu = new CustomContextMenu();
See Also