TreeView Nodes Clear

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!
Answered
0
0

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

 

  • You must to post comments
Best Answer
0
0

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

  • You must to post comments
0
0

Hi Frank,

All good with Nodes.Clear() now! Thanks.

Alex

  • You must to post comments
0
0

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

  • You must to post comments
0
0

Hi Alex,

I think you found the issue I was referring to on http://wisej.com/support/question/treeview-wrong-node-count.

Thanks 🙂

  • You must to post comments
0
0

Hi Alex,

I could reproduce the problem and logged WJ-7669 for it.

Best regards
Frank

  • You must to post comments
Showing 5 results
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Attachment
File Name Size
There are currently no files uploaded.
Maximum number of files 5, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json