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

context menu of Scheduler

2 Answers 210 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Jo
Top achievements
Rank 1
Jo asked on 10 Apr 2014, 03:41 AM
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?

Thanks!




2 Answers, 1 is accepted

Sort by
0
Jo
Top achievements
Rank 1
answered on 10 Apr 2014, 04:01 AM
Instead of clearing context menu item like, 
e.ContextMenu.Items.Clear();
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.

0
Stefan
Telerik team
answered on 10 Apr 2014, 09:47 AM
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: http://feedback.telerik.com/Project/154/Feedback/Details/110821.

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.

Regards,
Stefan
Telerik
 

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.

 
Tags
Scheduler and Reminder
Asked by
Jo
Top achievements
Rank 1
Answers by
Jo
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or