This is a migrated thread and some comments may be shown as answers.

Right-Click on Appointment Item

7 Answers 358 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
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

Sort by
0
Boyko Markov
Telerik team
answered on 18 Feb 2010, 03:15 PM
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.
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 ObjectByVal 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
Boyko Markov
Telerik team
answered on 25 Feb 2010, 07:36 AM
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.

Private defaultMenu As RadDropDownMenu
Private newMenu As RadDropDownMenu
 
Sub 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 If
End Sub

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.
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
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

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 Sub
0
Ivan Todorov
Telerik team
answered on 03 Sep 2012, 01:54 PM
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:
Private WithEvents ApproveMenuItem As New RadMenuItem
Private WithEvents DenyMenuItem As New RadMenuItem
Private separator As New RadMenuSeparatorItem
Dim appt As Telerik.WinControls.UI.AppointmentElement
 
Private 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 Sub

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
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
Scheduler and Reminder
Asked by
Mike Baldini
Top achievements
Rank 2
Answers by
Boyko Markov
Telerik team
Mike Baldini
Top achievements
Rank 1
Joel R
Top achievements
Rank 1
Denis Cilliers
Top achievements
Rank 1
Ivan Todorov
Telerik team
Share this question
or