TreeNode.Remove not working!

I have a strange problem. Let's look at this code:

TreeNode tn = TreeView1.FindNode("2009/08/12 (1)");     //OK, the Node is found

Now I need to remove node:

(THIS DOES NOT WORK!)

(for example, (I know that I do not need to use the TreeView1.FindNode () method, but I = -1 ))

            TreeNode tn1 = TreeView1.FindNode(tn.ValuePath);
            int i = TreeView1.Nodes.IndexOf(tn1);

or

            TreeView1.Nodes.Remove(tn);

The problem is that the codes above do not work, I mean that node is not deleted, why? TreeView is as follows:

alt text http://img130.imageshack.us/img130/230/71970321.png

+3
source share
2 answers

, TreeView .net , node, , node, , - :

Dim Padre As TreeNode = TreeView1.SelectedNode.Parent
If (Padre Is Nothing) Then
    TreeView1.Nodes.Remove(TreeView1.SelectedNode)
Else
    Padre.ChildNodes.Remove(TreeView1.SelectedNode)
End If

, !

+8

, node ? TreeView1.Nodes.IndexOf(tn1) -1, , node .

0

Source: https://habr.com/ru/post/1723588/


All Articles