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.
Unfortunately, activation email could not send to your email. Please try again.

Limiting context menu options

Thread ID:

Created:

Updated:

Platform:

Replies:

128502 Jan 25,2017 07:00 PM Jan 26,2017 02:39 AM Windows Forms 1
loading
Tags: ScheduleControl
Chris Iverson
Asked On January 25, 2017 07:00 PM

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.

Mohanraj Gunasekaran [Syncfusion]
Replied On January 26, 2017 02:39 AM

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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;