在目录树的afterchecked事件中写了如下代码:
If nd1.checked = False Then
If nd1.level = 0 Then
For Each nd As WinForm.TreeNode In tr2.Nodes
If nd1.name = nd.name Then '如果是取消勾选父节点直接将目标目录树中对应的节点清除
nd.Delete '删除节点
Exit For
End If
Next
ElseIf nd1.level = 1 Then
For Each nd As WinForm.TreeNode In tr2.AllNodes
msgbox(1)
If nd1.ParentNode.name = nd.ParentNode.name AndAlso nd1.name = nd.name Then '父子节点均相同才将目标目录树中对应的节点清除
nd.delete '删除节点
Exit For
End If
Next
End If
一行到到上面红色的代码时就出错(提示未将对象的引用设置到对象的实例),怎么都找不出原因?是哪里写错了
谢谢!