Mike Baldini
Top achievements
Rank 2
Mike Baldini
asked on 15 Feb 2010, 08:36 PM
Is there a way to have the appointment items on the calendar have their own context menu? We want to allow the users to right-click to delete, copy, etc. the appointment.
7 Answers, 1 is accepted
0
Hi Mike Baldini,
Thank you for contacting us. Unfortunately, this could not be done with the current version of RadScheduler for Winforms. We will provide an API in the next version which will allow you to subscribe to the visual appointment MouseDown and MouseUp events and then you can open a custom context menu in the event handler. Please feel free to ask us any questions you may have regarding RadScheduler.
Best wishes,
Boyko Markov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Thank you for contacting us. Unfortunately, this could not be done with the current version of RadScheduler for Winforms. We will provide an API in the next version which will allow you to subscribe to the visual appointment MouseDown and MouseUp events and then you can open a custom context menu in the event handler. Please feel free to ask us any questions you may have regarding RadScheduler.
Best wishes,
Boyko Markov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mike Baldini
Top achievements
Rank 1
answered on 19 Feb 2010, 05:41 PM
Actually, I figured out a way to get it done.
This snippet displays a custom context menu if you have an Appointment selected...
| Private Sub RadScheduler1_ContextMenuShowing(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.SchedulerContextMenuShowingEventArgs) Handles RadScheduler1.ContextMenuShowing |
| Dim appt As Telerik.WinControls.UI.AppointmentElement = TryCast(Me.RadScheduler1.FocusedElement, Telerik.WinControls.UI.AppointmentElement) |
| If Not appt Is Nothing Then |
| e.ContextMenu = Me.RadContextMenu1.DropDown |
| End If |
| End Sub |
0
Hi Mike Baldini,
It seems that I did not understand you correctly -- I thought that you need to open a specific context menu instance when you right click on an appointment and that kind of functionality is not supported yet. However the code snippet which you have written modifies the default context menu of RadScheduler. The code will work correctly, but if you show the context menu when an appointment is focused and then show it again for a cell, only the new context menu will be opened. I have modified the code snippet which you sent us.
The important thing in the source code is that you save the original menu instance and then show it again when the focused element is not an appointment element.
If you need more information, feel free to contact us.
Regards,
Boyko Markov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
It seems that I did not understand you correctly -- I thought that you need to open a specific context menu instance when you right click on an appointment and that kind of functionality is not supported yet. However the code snippet which you have written modifies the default context menu of RadScheduler. The code will work correctly, but if you show the context menu when an appointment is focused and then show it again for a cell, only the new context menu will be opened. I have modified the code snippet which you sent us.
Private defaultMenu As RadDropDownMenuPrivate newMenu As RadDropDownMenuSub radScheduler_ContextMenuShowing(sender As Object, e As SchedulerContextMenuShowingEventArgs) If Me.defaultMenu = Nothing Then Me.defaultMenu = e.ContextMenu End If If TryCast(Me.radScheduler.FocusedElement, AppointmentElement) <> Nothing Then newMenu = New RadDropDownMenu() Dim menuItem As New RadMenuItem("AppointmentItem1") newMenu.Items.Add(menuItem) e.ContextMenu = newMenu Else e.ContextMenu = Me.defaultMenu End IfEnd SubThe important thing in the source code is that you save the original menu instance and then show it again when the focused element is not an appointment element.
If you need more information, feel free to contact us.
Regards,
Boyko Markov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Joel R
Top achievements
Rank 1
answered on 25 Feb 2010, 02:49 PM
Below is how I change the menu and capture the event but how do you get a reference to the specific appointment in the event?
Below is the code I use to to change the menu and to set the event
| void radScheduler1_ContextMenuShowing(object sender, SchedulerContextMenuShowingEventArgs e) |
| { |
| // references |
| // http://www.telerik.com/community/forums/winforms/scheduler/right-click-menu.aspx |
| // http://www.telerik.com/help/winforms/modifying_existing_context_menu.html |
| if (Roles.IsUserInRole(Membership.GetUser().UserName, "OpsTeam") || Roles.IsUserInRole(Membership.GetUser().UserName, "Manager")) |
| { |
| RadMenuSeparatorItem separator = new RadMenuSeparatorItem(); |
| e.ContextMenu.Items.Add(separator); |
| this.m_ApproveMenuItem = new RadMenuItem("Approve Time Off"); |
| e.ContextMenu.Items.Add(this.m_ApproveMenuItem); |
| m_ApproveMenuItem.Click += new EventHandler(ContextMenuApprove_Click); |
| this.m_DenyMenuItem = new RadMenuItem("DENY Time Off"); |
| e.ContextMenu.Items.Add(this.m_DenyMenuItem); |
| m_DenyMenuItem.Click += new EventHandler(ContextMenuDeny_Click); |
| } |
| e.ContextMenu.Items[0].Text = "New Time Off"; |
| } |
| public void ContextMenuDeny_Click(object sender, EventArgs e) |
| { |
| MessageBox.Show("Deny menu item was clicked"); |
| } |
| public void ContextMenuApprove_Click(object sender, EventArgs e) |
| { |
| MessageBox.Show("Approve menu item was clicked"); |
| } |
0
Joel R
Top achievements
Rank 1
answered on 26 Feb 2010, 04:00 PM
I solved the problem. In my code sample I have the following
old
replacement
Now when the approveMenu item is clicked it calls the function AppointmentChangeStatus and passes in the appointment that the user right clicked on and then you can pass any additional parameters as with any normal function.
old
| m_ApproveMenuItem.Click += new EventHandler(ContextMenuApprove_Click); |
replacement
| m_ApproveMenuItem.Click += delegate(object s, EventArgs ev) |
| { AppointmentChangeStatus((Appointment)((AppointmentElement)e.Element).Appointment, "Parameter"); }; |
Now when the approveMenu item is clicked it calls the function AppointmentChangeStatus and passes in the appointment that the user right clicked on and then you can pass any additional parameters as with any normal function.
0
Denis Cilliers
Top achievements
Rank 1
answered on 30 Aug 2012, 04:06 PM
Having implmented this in VB.Net I get a strange result. the first time I right click on an appointment I get the correct menu the second time I get the basic menu?
Help pls
There should be some type of reset for the Dropdown Menu or have I got this wrong
Help pls
There should be some type of reset for the Dropdown Menu or have I got this wrong
Private WithEvents ApproveMenuItem As New RadMenuItem Private WithEvents DenyMenuItem As New RadMenuItem Dim appt As Telerik.WinControls.UI.AppointmentElement Private Sub RadScheduler1_ContextMenuShowing(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.SchedulerContextMenuShowingEventArgs) Handles radSchedulerDemo.ContextMenuShowing appt = TryCast(Me.radSchedulerDemo.FocusedElement, Telerik.WinControls.UI.AppointmentElement) If Not appt Is Nothing Then e.ContextMenu = Me.radSchedulerDemo.DropDownMenu 'Add New Items Dim separator As New RadMenuSeparatorItem e.ContextMenu.Items.Add(separator) ApproveMenuItem.Text = "Check In Booking" e.ContextMenu.Items.Add(ApproveMenuItem) DenyMenuItem.Text = "Cancel Booking" e.ContextMenu.Items.Add(DenyMenuItem) e.ContextMenu.Items(0).Text = "New Booking" Else e.ContextMenu.Items(0).Text = "New Booking" End If End Sub0
Hi Denis,
Thank you for writing.
Adding menu items to the default context menu of RadScheduler might result in behavior like the one you are describing, since RadScheduler modifies the menu items internally. I have modified your code to work as expected. You can refer to the following code snippet:
I hope you find this useful. Do not hesitate to write back if you have any further questions.
Kind regards,
Ivan Todorov
the Telerik team
Thank you for writing.
Adding menu items to the default context menu of RadScheduler might result in behavior like the one you are describing, since RadScheduler modifies the menu items internally. I have modified your code to work as expected. You can refer to the following code snippet:
Private WithEvents ApproveMenuItem As New RadMenuItemPrivate WithEvents DenyMenuItem As New RadMenuItemPrivate separator As New RadMenuSeparatorItemDim appt As Telerik.WinControls.UI.AppointmentElementPrivate Sub RadScheduler1_ContextMenuShowing(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.SchedulerContextMenuShowingEventArgs) Handles RadScheduler1.ContextMenuShowing appt = TryCast(Me.RadScheduler1.FocusedElement, Telerik.WinControls.UI.AppointmentElement) If Not appt Is Nothing Then e.ContextMenu = Me.RadScheduler1.DropDownMenu 'Add New Items ApproveMenuItem.Text = "Check In Booking" DenyMenuItem.Text = "Cancel Booking" If Not e.ContextMenu.Items.Contains(ApproveMenuItem) Then e.ContextMenu.Items.Add(separator) e.ContextMenu.Items.Add(ApproveMenuItem) e.ContextMenu.Items.Add(DenyMenuItem) Else ApproveMenuItem.Visibility = Telerik.WinControls.ElementVisibility.Visible DenyMenuItem.Visibility = Telerik.WinControls.ElementVisibility.Visible separator.Visibility = Telerik.WinControls.ElementVisibility.Visible End If End If e.ContextMenu.Items(0).Text = "New Booking"End SubI hope you find this useful. Do not hesitate to write back if you have any further questions.
Kind regards,
Ivan Todorov
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>