你们是专业的,我不是专业的,您还是指点我在原代码上改一下吧
Dim tr As WinForm.TreeView
tr = e.Form.Controls("TreeView2")
Dim nd As WinForm.TreeNode
nd = tr.SelectedNode
Dim pd As WinForm.TreeNode
pd = nd.ParentNode
Dim sd As winform.treenode
sd = pd.ParentNode
Dim wd As WinForm.TreeNode
wd = sd.ParentNode
If nd IsNot Nothing Then
If nd.Level = 5 Then
MessageBox.Show("最多允许六层结构!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
Dim dr As DataRow = DataTables("组织机构和职责").AddNew
If nd.Level = 0 Then
dr("企业名称") = nd.Text
dr("部门设置") = "新节点"
ElseIf nd.Level = 1
dr("企业名称") = pd.Text
dr("部门设置") = nd.text
dr("岗位设置") = "新节点"
ElseIf nd.Level = 2
dr("企业名称") = sd.Text
dr("部门设置") = pd.Text
dr("岗位设置") = nd.text
dr("第四层机构设置") = "新节点"
ElseIf nd.Level = 3
dr("企业名称") = wd.Text
dr("部门设置") = sd.Text
dr("岗位设置") = pd.Text
dr("第四层机构设置") = nd.text
dr("第五层机构设置") = "新节点"
ElseIf nd.Level = 4
dr("企业名称") = wd.ParentNode.Text
dr("部门设置") = wd.Text
dr("岗位设置") = sd.Text
dr("第四层机构设置") = pd.Text
dr("第五层机构设置") = nd.text
dr("第六层机构设置") = "新节点"
End If
nd = nd.Nodes.Add("新节点")
tr.SelectedNode = nd
tr.Select()
tr.BeginEdit()
End If
End If
谢谢了!