We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Limiting context menu options

Hello,

In the scheduler control I want to limit the context menu to just a few items.

Specifically I only want the options for

Month view
Week view

Could you provide a sample that gives only those options or for a custom menu that will only allow those options

Thanks.

1 Reply

MG Mohanraj Gunasekaran Syncfusion Team January 26, 2017 07:39 AM UTC

Hi Chris, 

Thanks for using Syncfusion products. 

In order to set the custom context menu for MonthView and WekView in ScheduleControl , you can use the ContextMenuStrip property, ScheduleAppontMentClick event and SetUpContextMenu event to handle the context menu. Please refer the below code snippet and refer the below attached sample 

Code snippet 
ScheduleGrid grid; 
ContextMenuStrip contextMenu; 
grid = this.scheduleControl1.GetScheduleHost(); 
contextMenu = new System.Windows.Forms.ContextMenuStrip(); 
ToolStripItem item = new ToolStripMenuItem("Delete", (Image)(ScheduleGrid.GetBitmap("Delete.png")), new EventHandler(deleteItemClick)); 
contextMenu.Items.Add(item); 
grid.ContextMenuStrip = null; 
this.scheduleControl1.SetupContextMenu += scheduleControl1_SetupContextMenu; 
this.scheduleControl1.ScheduleAppointmentClick += scheduleControl1_ScheduleAppointmentClick; 
 
private void scheduleControl1_ScheduleAppointmentClick(object sender, ScheduleAppointmentClickEventArgs e) 
{ 
 
    if ((e.ClickType == ScheduleAppointmentClickType.RightClick) && (this.scheduleControl1.ScheduleType == ScheduleViewType.Month || this.scheduleControl1.ScheduleType == ScheduleViewType.Week)) 
    { 
        this.scheduleControl1.ContextMenuStrip = contextMenu; 
    } 
} 

void scheduleControl1_SetupContextMenu(object sender, CancelEventArgs e) 
{ 
    if (this.scheduleControl1.ScheduleType == ScheduleViewType.Month || this.scheduleControl1.ScheduleType == ScheduleViewType.Week) 
        e.Cancel = true; 
} 

Sample link: ScheduleControl 

Regards, 
Mohanraj G. 


Loader.
Up arrow icon