Treeview crash

6 posts, 1 answers
  1. Frédéric
    Frédéric avatar
    11 posts
    Member since:
    Jul 2008

    Posted 12 Aug 2008 Link to this post

    Hi,

    When I move by mistakes a node on the node over him, the application crash with the error bellow.

    To reproduce this,
    > Create a treeView with 2 nodes inside!
    > Move the second node into the first one,
    > Do it again (Move the second node that is already into the first one exactly as you did before)

    I hope you can reproduce it and tell me how to avoid this problem.

    Best regards, Fred




    System.ArgumentOutOfRangeException was unhandled
      Message="Index must be within the bounds of the List.\r\nParameter name: index"
      Source="mscorlib"
      ParamName="index"
      StackTrace:
           at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
           at System.Collections.Generic.List`1.Insert(Int32 index, T item)
           at Telerik.WinControls.UI.RadTreeNodeCollection.InsertItem(Int32 index, RadTreeNode node)
           at System.Collections.ObjectModel.Collection`1.Add(T item)
           at Telerik.WinControls.UI.RadTreeView.FinalizeDrop(RadTreeNode targetNode, RadTreeNode draggedNode, ArrowDirection arrowDirection, RadTreeView endTree)
           at Telerik.WinControls.UI.RadTreeView.OnMouseUp(MouseEventArgs e)
           at System.Windows.Forms.Control.WmMouseUp(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(Int32 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 WindowsApplication1.Program.Main() in C:\Documents and Settings\badoux0f\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Program.cs:line 17
           at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()



  2. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 13 Aug 2008 Link to this post

    Hi Frédéric,

    Thank you for writing.
    This is due to a undocumented behavior of the Add method of the tree node collection that was fixed for the Q2 2008 release. This issue is already fixed and will not be present in the upcoming Q2 2008 SP1 release.

    Best wishes,
    Jordan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Frédéric
    Frédéric avatar
    11 posts
    Member since:
    Jul 2008

    Posted 13 Aug 2008 Link to this post

    Thanks for this answer.

    So actually, there is no work around if the users make a wrong manipulation?

    Do you know when the Q2 2008 SP1 will be release???

  5. Answer
    Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 14 Aug 2008 Link to this post

    Hello Frédéric,

    The SP1 release is scheduled for the end of this month.
    In the meantime you could try canceling the add operation if the collection already contains the node like:
    public Form1() 
            { 
                this.radTreeView1.Nodes.CollectionChanging += new Telerik.WinControls.Data.NotifyCollectionChangingEventHandler(Nodes_CollectionChanging); 
            } 
     
            void Nodes_CollectionChanging(object sender, Telerik.WinControls.Data.NotifyCollectionChangingEventArgs e) 
            { 
                if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Add) 
                { 
                    if ((sender as RadTreeNodeCollection).Contains(e.NewItems[0] as RadTreeNode)) 
                    { 
                        e.Cancel = true
                    } 
                } 
            } 

    Don't hesitate to contact us if you have other questions.

    Greetings,
    Jordan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Mehdi
    Mehdi avatar
    1 posts
    Member since:
    Jun 2011

    Posted 20 Jun 2011 Link to this post

    Hi,
    First of all  thank  you for your  great  forum.

    Unfortunately, I have the same problem in Q1 2011 when I drag a node to the top of the first row and drop it the application crash with the error bellow!

    "Index must be within the bounds of the List. 
     Parameter name: index"

    I hope you can help me handle it?!

    Thanks and best regards,


  7. Svett
    Admin
    Svett avatar
    728 posts

    Posted 22 Jun 2011 Link to this post

    Hello Mehdi,

    Please find the answer of your question in your thread "Drag & Drop Crash on Moving a Node to the Top Row!".

    All the best,
    Svett
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Back to Top
UI for WinForms is Visual Studio 2017 Ready