context menu of Scheduler

3 posts, 0 answers
  1. Jo
    Jo avatar
    4 posts
    Member since:
    Apr 2014

    Posted 09 Apr 2014 Link to this post

    On the Context Menu Showing Event of radScheduler,
    I clear the current context menu then add some other RadMenuItems depending on the scenario.

    on the first right click, the context menu shows.

    but after right clicking anywhere on the RadScheduler (in any ActiveViewType)
    the program crashes.

    I got this error.

    System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
       at System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32 index)
       at Telerik.WinControls.RadItemCollection.get_Item(Int32 index)
       at Telerik.WinControls.UI.MonthViewAreaElement.Scheduler_MouseDown(Object sender, MouseEventArgs e)
       at Telerik.WinControls.UI.MonthViewAreaElement.HandleSchedulerMouseDown(MouseEventArgs e)
       at Telerik.WinControls.UI.RadSchedulerElement.scheduler_MouseDown(Object sender, MouseEventArgs e)
       at System.Windows.Forms.Control.OnMouseDown(MouseEventArgs e)
       at Telerik.WinControls.RadControl.OnMouseDown(MouseEventArgs e)
       at Telerik.WinControls.UI.RadScheduler.OnMouseDown(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at Telerik.WinControls.RadControl.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at ICAM.Global.Main() in D:\TFS 20131025\ICAM4\ICAM4_v2\ICAM\Global.cs:line 151

    Global.cs:line 151 is Application.Run(Form mainForm)
    succeeding details show that it is on the library. 

    I put a break point on the first line of ContextMenuShowing, but error occurs right before it reaches the breakpoint.

    I am using Telerik Q1 2014 for WinForms.
    Could you help me solve this? Or am I missing some restrictions on using context menu in RadScheduler?


  2. Jo
    Jo avatar
    4 posts
    Member since:
    Apr 2014

    Posted 09 Apr 2014 Link to this post

    Instead of clearing context menu item like, 
    i just collapsed each item as a work around. Please advise for better solution/workaround
    for (int i = 0; i < e.ContextMenu.Items.Count; i++)
                    e.ContextMenu.Items[i].Visibility = Telerik.WinControls.ElementVisibility.Collapsed;

    Now, i would like to know why i got the said error.

  3. Stefan
    Stefan avatar
    2911 posts

    Posted 10 Apr 2014 Link to this post

    Hi Jo,

    Thank you for writing.

    We are aware of this issue and we will address it in a future release. Here you can track its status:

    To work around it, instead of clearing the items in the context menu, just make them invisible:
    void radScheduler1_ContextMenuShowing(object sender, SchedulerContextMenuShowingEventArgs e)
       // e.ContextMenu.Items.Clear();
        foreach (RadMenuItem item in e.ContextMenu.Items)
            item.Visibility = ElementVisibility.Collapsed; 
        e.ContextMenu.Items.Add(new RadMenuItem("your item"));

    I hope this helps.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top