Removing SubNodes - HELP!
I have this code in the AfterCollapse event of my TreeView control:-
Code:
Dim subNode As TreeNode
For Each subNode In e.Node.Nodes
MessageBox.Show("removing " & subNode.Text)
subNode.Remove()
Next
e.Node.Nodes.Add("")
I want the control to remove all sub-nodes after it has collapsed and then add a blank dummy one at the end.
It falls over about half-way through with a "Object reference not set to an instance of an object" error.
It appears to be trying to remove the same sub-node twice!
Any ideas???
Removing SubNodes - RESOLVED
Did it this way instead:-
Code:
Dim i As Integer
For i = 1 To e.Node.GetNodeCount(False)
e.Node.Nodes.RemoveAt(0)
Next
e.Node.Nodes.Add("")
Cheers.