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

RadTreeView Scrollbar fall with NullReferenceExceprion

3 Answers 146 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 02 Jul 2013, 11:17 AM
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.

3 Answers, 1 is accepted

Sort by
0
Accepted
George
Telerik team
answered on 04 Jul 2013, 12:29 PM
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 >>
0
Jeff
Top achievements
Rank 1
answered on 28 Oct 2013, 08:46 PM
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

0
George
Telerik team
answered on 31 Oct 2013, 03:39 PM
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 >>
Tags
Treeview
Asked by
Thomas
Top achievements
Rank 1
Answers by
George
Telerik team
Jeff
Top achievements
Rank 1
Share this question
or