Hi guys,
I have a treeview, tv, and a button on a form. In the button’s click event I have the following code:
tv.Nodes.Clear();
var root = new TreeNode();
root.Text = “Root Node”;
tv.Nodes.Add(root);
for (int i = 1; i <= 5; i++)
{
var node = new TreeNode();
node.Text = “Node ” + i.ToString();
root.Nodes.Add(node);
}
tv.ExpandAll();
I would expect that every time I click the button I get the same treeview, since the first line of my code clears the treeview. However, a new “Root Node” is added every time, and the treeview keeps extending. Am I missing something?
Best,
Alex
Hi Alex & Tiago,
build 1.2.71 is now available including a fix for WJ-7669.
Can you guys please retest your applications ? Thanks !
Best regards
Frank
Hi Frank,
All good with Nodes.Clear() now! Thanks.
Alex
Hi Tiago,
To be honest I was suspecting they might be related, since after tv.Nodes.Clear() the count was zero but of course the treeview had all the previous nodes. But I wasn’t sure. After all it was easy to reproduce! 🙂
Thanks Tiago!
Alex
Hi Alex,
I think you found the issue I was referring to on https://wisej.com/support/question/treeview-wrong-node-count.
Thanks 🙂
Hi Alex,
I could reproduce the problem and logged WJ-7669 for it.
Best regards
Frank