Foxtable(狐表)用户栏目专家坐堂 → 遍历目录树的节点出错?


  共有1564人关注过本帖平板打印复制链接

主题:遍历目录树的节点出错?

帅哥哟,离线,有人找我吗?
happyft
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1911 积分:17032 威望:0 精华:0 注册:2014/7/29 19:09:00
遍历目录树的节点出错?  发帖心情 Post By:2016/4/10 22:39:00 [只看该作者]

在目录树的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

一行到到上面红色的代码时就出错(提示未将对象的引用设置到对象的实例),怎么都找不出原因?是哪里写错了
谢谢!

 回到顶部