Category / Section
How to trigger the event while deleting an appointment using contextmenu in WinForms ScheduleControl?
1 min read
Delete item in contextmenustrip
There is no default event support for deleting the appointment in ScheduleControl. But this can be achieved by deleting the default delete item in ContextMenuStrip and adding the new custom delete item with the new event.
C#
private ContextMenuStrip strip; //Get the menu items. strip = this.scheduleControl1.GetScheduleHost().ContextMenuStrip; //Delete the default delete item in ContextMenuStrip. strip.Items.RemoveAt(4); //Create a new menu item with event for delete support. ToolStripItem item = new ToolStripMenuItem("Delete Item", (Image)(ScheduleGrid.GetBitmap("Delete.png")), new EventHandler(deleteItemClick)); //Add the new item to ContextMenuStrip. strip.Items.Insert(4, item); //Customize the event when the item was deleted. private void deleteItemClick(object sender, EventArgs e) { this.scheduleControl1.PerformDeleteItemClick(); }
VB
Private strip As ContextMenuStrip 'Get the menu items. strip = Me.scheduleControl1.GetScheduleHost().ContextMenuStrip 'Delete the default delete item in ContextMenuStrip. strip.Items.RemoveAt(4) 'Create a new menu item with event for delete support. Dim item As ToolStripItem = New ToolStripMenuItem("Delete Item", CType(ScheduleGrid.GetBitmap("Delete.png"), Image), New EventHandler(AddressOf deleteItemClick)) 'Add the new item to menu. strip.Items.Insert(4, item) 'Customize the event when the item was deleted. private void deleteItemClick(Object sender, EventArgs e) Me.scheduleControl1.PerformDeleteItemClick()
Samples: