click event handler for contextmenu items

7 posts, 1 answers
  1. revox
    revox avatar
    26 posts
    Member since:
    May 2010

    Posted 21 Sep 2010 Link to this post

    I think this is an easy one, but I'm not seeing how to do it. I want to write event handlers for the menu items in the radscheduler context menu. For example, I want to write the code for "Next View."

    Anybody done this? Thanks in advance for your help. I hope you get lots of points. :)
  2. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 24 Sep 2010 Link to this post

    Hello revox,

    Thank you for writing. If I understand correctly, you want to navigate to the next view and navigate to the previous view through the context menu. In this case when you click the next view item in the context menu you should call method
    RadScheduler.NavigateToNextViewCommand.ExecuteCommand(this.associatedScheduler);
    For the previous view, you could use
    RadScheduler.NavigateToPreviousViewCommand.ExecuteCommand(this.associatedScheduler);

    I hope that this will help you. If you have other questions feel free to contact us.

    Sincerely yours,
    Dobry Zranchev
    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. revox
    revox avatar
    26 posts
    Member since:
    May 2010

    Posted 28 Sep 2010 Link to this post

    Thanks for your response! I want to override the click event handlers for the context menu items. (I'm finally getting back to this task.)

    It's not the code you wrote that had me stumped. It's how to override the click event handler. As I said originally, this may be an easy one. I'll search the forum for an answer.
  5. Brennan
    Brennan avatar
    39 posts
    Member since:
    Sep 2010

    Posted 28 Sep 2010 Link to this post

    I don't usually try to "override" the Telerik menu items click events, I usually just make their menu items invisible (The one's I don't want/need), add my own menu item, and then handle my menu item's click event.  The code is as follows:

    Private Sub radScheduler1_ContextMenuShowing(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.SchedulerContextMenuShowingEventArgs) Handles radScheduler1.ContextMenuShowing
        
    'REMOVES NextView FROM CONTEXT MENU
    Dim i As Integer = 0
    Do While i < e.ContextMenu.Items.Count
       If e.ContextMenu.Items(i).Text = "NextView" Then
          e.ContextMenu.Items(i).Visibility = Telerik.WinControls.ElementVisibility.Collapsed
          Exit Do
        End If
        i += 1
    Loop
      
    'ADD YOUR OWN NEXTVIEW BUTTON
    Dim changeView As RadMenuItem = New RadMenuItem()
    e.ContextMenu.Items.Insert(0,changeView)
    changeView.Text = "change view"
       
    'CREATE THE HANDLER FOR THE BUTTON
    AddHandler changeView.Click, AddressOf changeView_Click
        
    End Sub
  6. revox
    revox avatar
    26 posts
    Member since:
    May 2010

    Posted 28 Sep 2010 Link to this post

    Thanks for the tip!
  7. revox
    revox avatar
    26 posts
    Member since:
    May 2010

    Posted 30 Sep 2010 Link to this post

    I got back to this problem and used your approach. It works! Thanks much!
  8. Answer
    Brennan
    Brennan avatar
    39 posts
    Member since:
    Sep 2010

    Posted 30 Sep 2010 Link to this post

    Glad I could help.
Back to Top
UI for WinForms is Visual Studio 2017 Ready