Dim tr As WinForm.TreeView
Dim nd As WinForm.TreeNode=tr.SelectedNode
tr = e.Form.Controls("TreeView1")
tr.ExpandAll
If tr.Nodes.Count=0 Then
MessageBox.Show("请先增加根节点!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
'nd = tr.SelectedNode
Dim nm As String ="点" & Vars("numbh")
If nd IsNot Nothing Then
Select nd.Level
Case 0
If nd.Nodes.Contains(nm) = False
nd.Nodes.Add(nm)
Dim dr As DataRow = DataTables("角色管理").AddNew
dr("角色")=nd.Text & "\" & "点" & Vars("numbh")
Vars("numbh")=Vars("numbh")+1
tr.Select
tr.BeginEdit
tr.ExpandAll
End If
Case 1
If nd.Nodes.Contains(nm) = False
nd.Nodes.Add(nm)
Dim dr As DataRow = DataTables("角色管理").AddNew
dr("角色")=nd.ParentNode.Text & "\" & nd.Text & "\" & "点" & Vars("numbh")
Vars("numbh")=Vars("numbh")+1
tr.SelectedNode = nd
tr.Select
tr.BeginEdit
tr.ExpandAll
End If
Case 2
If nd.Nodes.Contains(nm) = False
nd.Nodes.Add(nm)
Dim dr As DataRow = DataTables("角色管理").AddNew
dr("角色")=nd.ParentNode.ParentNode.Text & "\" & nd.ParentNode.Text & "\" & nd.Text & "\" & "点" & Vars("numbh")
Vars("numbh")=Vars("numbh")+1
tr.SelectedNode = nd
tr.Select
tr.BeginEdit
tr.ExpandAll
End If
Case Else
MessageBox.Show("最多允许四层节点!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End Select
End If
End If