Foxtable(狐表)用户栏目专家坐堂 → 多级目录树问题


  共有2010人关注过本帖树形打印复制链接

主题:多级目录树问题

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


加好友 发短信
等级:一尾狐 帖子:485 积分:4069 威望:0 精华:0 注册:2015/12/16 8:22:00
多级目录树问题  发帖心情 Post By:2016/6/6 12:55:00 [只看该作者]

Dim tr As WinForm.TreeView
Dim
 nd As WinForm.TreeNode
tr = e.Form.Controls(
"TreeView1")
nd = tr.SelectedNode

If
 nd IsNot Nothing Then
    
If nd.Level = 2 Then
        MessageBox.Show(
"最多允许三层节点!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Else
        
Dim dr As DataRow = DataTables("表A").AddNew
        If
 nd.Level = 0 
Then
            dr(
"大类") = nd.Text
            dr(
"二类") = "新节点"
        
ElseIf nd.Level = 1
            dr(
"大类") = nd.ParentNode.Text
            dr(
"二类") = nd.text
            dr(
"三类") = "新节点"
        
End If
        nd = nd.Nodes.Add(
"新节点")
        tr.SelectedNode = nd
        tr.
Select()
        tr.BeginEdit()

    End
 
If
End
 If


发现若修改为5层的话,发现第5不能输入只能修改,请问若有5层的话代码应该如何修改?

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/6/6 14:20:00 [只看该作者]

Dim tr As WinForm.TreeView
Dim nd As WinForm.TreeNode
tr = e.Form.Controls("TreeView1")
nd = tr.SelectedNode
If nd IsNot Nothing Then
    If nd.Level = 4 Then
        MessageBox.Show("最多允许5层节点!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Else
        Dim dr As DataRow = DataTables("表A").AddNew
        If nd.Level = 0 Then
            dr("大类") = nd.Text
            dr("二类") = "新节点"
        ElseIf nd.Level = 1
            dr("大类") = nd.ParentNode.Text
            dr("二类") = nd.text
            dr("三类") = "新节点"
        ElseIf nd.level = 2
            Dim ary() As String = nd.fullPath.split("\")
            dr("大类") = ary(0)
            dr("二类") = ary(1)
            dr("三类") = ary(2)
            dr("4类") = "新节点"
        ElseIf nd.level = 3
            Dim ary() As String = nd.fullPath.split("\")
            dr("大类") = ary(0)
            dr("二类") = ary(1)
            dr("三类") = ary(2)
            dr("4类") = ary(3)
            dr("5类") = "新节点"
           
        End If
        nd = nd.Nodes.Add("新节点")
        tr.SelectedNode = nd
        tr.Select()
        tr.BeginEdit()
    End If
End If

 回到顶部
帅哥哟,离线,有人找我吗?
benwong2013
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:485 积分:4069 威望:0 精华:0 注册:2015/12/16 8:22:00
  发帖心情 Post By:2016/6/6 15:24:00 [只看该作者]

Dim tr As WinForm.TreeView
Dim nd As WinForm.TreeNode
tr = e.Form.Controls("TreeView1")
nd = tr.SelectedNode
If nd IsNot Nothing Then
    If nd.Level = 4 Then
        MessageBox.Show("最多允许五层节点!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Else
        Dim dr As DataRow = DataTables("B_Room").AddNew
        If nd.Level = 0 Then
            dr("仓库一级") = nd.Text
            dr("仓库二级") = "新节点"
        ElseIf nd.Level = 1
            dr("仓库一级") = nd.ParentNode.Text
            dr("仓库二级") = nd.text
            dr("仓库三级") = "新节点"
        ElseIf nd.Level = 2
            dr("仓库一级") = nd.ParentNode.Text
            dr("仓库二级") = nd.text
            dr("仓库三级") = nd.text
            dr("仓库四级") = "新节点"            
        ElseIf nd.Level = 3
            dr("仓库一级") = nd.ParentNode.Text
            dr("仓库二级") = nd.text
            dr("仓库三级") = nd.text
            dr("仓库四级") = nd.text
            dr("仓库伍级") = "新节点"
        ElseIf nd.Level = 4
            dr("仓库一级") = nd.ParentNode.Text
            dr("仓库二级") = nd.text
            dr("仓库三级") = nd.text
            dr("仓库四级") = nd.text
            dr("仓库伍级") = nd.text
        End If
        nd = nd.Nodes.Add("新节点")
        tr.SelectedNode = nd
        tr.Select()
        tr.BeginEdit()
    End If
End If


图片点击可在新窗口打开查看此主题相关图片如下:5.png
图片点击可在新窗口打开查看

如上面修改的代码,我发现红色标识的有问题,并且五级的时候是无法输入,请问如何处理?
[此贴子已经被作者于2016/6/6 15:26:00编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/6/6 15:26:00 [只看该作者]

看2楼来改,不会做上传实例啊

 回到顶部