以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  多级目录树问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=85942)

--  作者:benwong2013
--  发布时间: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层的话代码应该如何修改?

--  作者:大红袍
--  发布时间: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
--  发布时间: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编辑过]

--  作者:大红袍
--  发布时间:2016/6/6 15:26:00
--  
看2楼来改,不会做上传实例啊