Is this possible?
-
I’ve got a treeview control on a windows form and the treeview is already populated. Is their a way to traverse through the tree looking for a node with certain text, then remove that node when the matched node with the text is found? I’m passing in the string text of the node I want to delete from another form, the tree is located on the parent form. The tree looks like this. I want to delete Smith when it's passed in from the other form. Employee Johnson Smith Employee Location Boston Seattle If this is possible any help would be greatly appreciated. The code below won’t work since I don’t want to select the node manually. TreeNode tn = treeView1.SelectedNode; treeView1.Nodes.Remove(tn); :-D
-
I’ve got a treeview control on a windows form and the treeview is already populated. Is their a way to traverse through the tree looking for a node with certain text, then remove that node when the matched node with the text is found? I’m passing in the string text of the node I want to delete from another form, the tree is located on the parent form. The tree looks like this. I want to delete Smith when it's passed in from the other form. Employee Johnson Smith Employee Location Boston Seattle If this is possible any help would be greatly appreciated. The code below won’t work since I don’t want to select the node manually. TreeNode tn = treeView1.SelectedNode; treeView1.Nodes.Remove(tn); :-D
Just use a for loop to traverse the tree, inside the for loop check the text value of the node. -Nick Parker