Replace the built-in Context menu with custom Context menu


How to replace the built-in Context menu with custom Context menu

Steps to Complete:

1. Hide built-in Context menu: Use BeforeContextMenuShow event and set e.Cancel to True.

private void C1Schedule1_BeforeContextMenuShow(object sender, C1.Win.C1Schedule.BeforeContextMenuShowEventArgs e)
              e.Cancel = true;

2. Add custom Context menu. Use MouseClick event and check if Right mouse button is pressed. If yes, create an instance of System.Windows.Forms.ContextMenu class and add MenuItem objects as needed, to its MenuItems collection.

private void C1Schedule1_MouseClick(object sender, MouseEventArgs e)
            if(e.Button== MouseButtons.Right)
                ContextMenu customCntxtMenu = new ContextMenu();
                customCntxtMenu.MenuItems.Add("&New Appointment", new EventHandler(NewAppointment));
                customCntxtMenu.MenuItems.Add("&New Recurring Appointment", new EventHandler(NewRecurringAppointment));
                customCntxtMenu.MenuItems.Add("&Today", new EventHandler(Today));
                customCntxtMenu.MenuItems.Add("&Go to Date", new EventHandler(GoToDate));
                customCntxtMenu.MenuItems.Add("&Next 7 days", new EventHandler(Next7Days));
                customCntxtMenu.MenuItems.Add("&Import", new EventHandler(ImportData));
                customCntxtMenu.MenuItems.Add("&Export", new EventHandler(ExportData));

                c1Schedule1.ContextMenu = customCntxtMenu;

Ruchir Agarwal