RadTreeView Scrollbar fall with NullReferenceExceprion

4 posts, 1 answers
  1. Thomas
    Thomas avatar
    22 posts
    Member since:
    Oct 2012

    Posted 02 Jul 2013 Link to this post

    Hi Telerik, 

    There is a bug with RadTreeView, and scrollbar.

    Download source files:
    https://dl.dropboxusercontent.com/u/48038910/TreeScrollsCrash.rar

    Steps to reproduce the bug:

    1. Run attached application;
    2. Push fill button;
    3. Scroll tree to the end;
    4. Push delete button
    Program crashes with null reference exception.
  2. Answer
    George
    Admin
    George avatar
    500 posts

    Posted 04 Jul 2013 Link to this post

    Hello Thomas,

    Thank you for contacting us.

    I was able to reproduce the issue described by you. It is a bug in the treeView's traverser. A temporary workaround I can give you is to reset this traverser before clearing the nodes.
    private void DeleteButton_Click(object sender, EventArgs e)
    {
        radTreeView.TreeViewElement.Scroller.Traverser.Reset();
        radTreeView.BeginUpdate();
     
        foreach (var node in radTreeView.Nodes[radTreeView.Nodes.Count - 1].Nodes.ToArray())
        {
            node.Remove();
        }
     
        for (int i = 0; i < 99; i++)
        {
            radTreeView.Nodes[radTreeView.Nodes.Count - 1].Nodes.Add(new RadTreeNode("aasdasd"));
        }
         
        radTreeView.EndUpdate();
    }

    Additionally I have logged the issue in our Public Issue Tracking System. You can follow its status and vote for it on this address RadTreeView - exception when clearing child nodes. I have also updated your Telerik Points as a token of gratitude for your contribution.

    For any further questions, do not hesitate to contact us.
     
    Regards,
    George
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jeff
    Jeff avatar
    14 posts
    Member since:
    Aug 2013

    Posted 28 Oct 2013 Link to this post

    Hello George, or whichever Telerik support staff comes across this first,

    Thomas found the same issue I've found and reproduced with a small test app.  (Thank you Thomas.)  I've incorporated the workaround you suggested and that does prevent the NullReferenceException.  However, the subsequent problem is that the list of nodes is truncated in the view until you scroll up and back.

    My sample app, with the workaround, is here:

    https://www.dropbox.com/s/08brbkam7swimk1/ExplodingTreeNodes.zip

    Note: the tree nodes are no longer exploding.  ;)

    My sample tree contains 1 root node with 50 subnodes.

    Steps to reproduce:

    1. Scroll to the end of the tree
    2. Observe that the last item in the tree view is "Subitem 50"
    3. Select, for example, item "Subitem 45"
    4. Click the "Remove" button
    5. Scroll back to the bottom
    6. Observe that the last item visible in the tree view is now "Subitem 49", although you can still see the tree line at the bottom that would lead to item 50.

    The only way to fix the view is to scroll all the way to the top and back down.  If you scroll anything less than all the way to the top the view remains incorrectly truncated.

    Regards,
    ~Jeff

  5. George
    Admin
    George avatar
    500 posts

    Posted 31 Oct 2013 Link to this post

    Hi Jeff,

    Thank you for contacting us.

    It really appears that the scroll is in invalid state after the node has been removed. As an addition to the old workaround you can update the scroll's value, this can be done immediately after the traverser has been reset:
    this.treeView.TreeViewElement.Scroller.Traverser.Reset();
    this.treeView.TreeViewElement.Scroller.UpdateScrollValue();

    I will make sure to update the workaround given in the PITS issue. I have updated your Telerik Points for bringing this to our attention.

    Let me know if you have any other questions.

    Regards,
    George
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top