Foxtable(狐表)用户栏目专家坐堂 → 五级目录树的建立


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

主题:五级目录树的建立

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


加好友 发短信
等级:三尾狐 帖子:641 积分:5194 威望:0 精华:0 注册:2018/5/19 22:27:00
五级目录树的建立  发帖心情 Post By:2018/8/1 17:46:00 [只看该作者]

“编辑目录树之二”是三级目录树的建立,请问五级目录树的下列代码应如何修改

5、“增加子节点”按钮的Click事件代码:

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

6、“删除”按钮的Click事件代码:

Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim
nd As WinForm.TreeNode = tr.SelectedNode
If
nd IsNot Nothing Then
    Dim
pth() As String = nd.FullPath.Split("\")
    Select
Case nd.Level
    Case
0
       
DataTables("
A").DeleteFor("大类 = '" & pth(0) & "'")
    Case
1
       
DataTables("
A").DeleteFor("大类 = '" & pth(0) & "' And 二类 = '" & pth(1) & "'")
    Case
2
       
DataTables("
A").DeleteFor("大类 = '" & pth(0) & "' And 二类 = '" & pth(1) & "' And 三类 = '" & pth(2) & "'")
    End
Select
    nd.Delete()
End
If
tr.Select()

7、目录树AfterEditNode事件代码:

If e.NewText = "" Then
   
e.Cancel = True
    Return
End If
Dim
pth() As String = e.Node.FullPath.Split("\")
Select Case
e.node.Level
    Case
0
        DataTables(
"A").ReplaceFor("大类",e.NewText,"大类 = '" & pth(0) & "'")
    Case
1
        DataTables(
"A").ReplaceFor("二类",e.NewText,"大类 = '" & pth(0) & "' And 二类 = '" & pth(1) & "'")
    Case
2
        DataTables(
"A").ReplaceFor("三类",e.NewText,"大类 = '" & pth(0) & "' And 二类 = '" & pth(1) & "' And 三类 = '" & pth(2) & "'")
End Select

e
.Node.Name = e.NewText


 回到顶部
总数 12 1 2 下一页