To remove an node, you either need to know its Index or its unique key (if you gave it one). Then you use the following syntax:
TreeView1.Nodes.Remove IndexOrKey
The following example first removes a node which key is "root", and then removes a node which key is 12.
TreeView1.Nodes.Remove "root"
TreeView1.Nodes.Remove 12
Note that if a node has sub items when it is removed, all its sub items are removed too.
If you want to remove all the nodes in the TreeView, you can use the Clear method:
TreeView1.Nodes.Clear
Comments