I have the below sub which checks all of a node's child nodes in a Windows form treeview when the node is checked. I get the error stated in the subject whenever I click it, but this only happens when settings the checked property. If I just run the commented out MsgBox line, it works fine with no errors.
Private Sub TreeView1_AfterCheck(ByVal sender As System.Object, ByVal e As _
TreeViewEventArgs) Handles TreeView1.AfterCheck
For Each s As TreeNode In TreeView1.Nodes
If s.Checked = True Then
For i As Integer = 0 To s.Nodes.Count - 1
MsgBox(s.Nodes(i).Text)
s.Nodes(i).Checked = True
Next
End If
Next
End Sub
As it is a StackOverflow Exception, this seemed like the best place to ask about it!