I get a system.arguentoutofrange exception with the following code. Both conditional statements, unselecting and clearing, give this error. If this were true the conditional statements would never let me get to that point. This occurs when I have a form with a tree, I go to a dialgoue form where user can change the heirachry of the tree(save in a xml file) then upon closing the dialgue, I want to clear the tree on original page and rebuild from updated xml heirarchy file. This seems to be a bug in your software.....
If Me.tvwReports.SelectedNodes.Count > 0 Then
If Not tvwReports.SelectedNodes(0) Is Nothing Then
Me.tvwReports.SelectedNodes(0).Selected = False
End If
If tvwReports.Nodes.Count > 0 Then
tvwReports.Nodes(i).Remove()
i = i + 1
End While
I don't have a call stack to show, but I can confirm that you're not the only one to have seen this problem. I am using your methodology to remove the selected nodes one-by-one and that gets the job done.