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("二类") = "二类"
nd = nd.Nodes.Add("二类")
ElseIf nd.Level = 1
dr("大类") = nd.ParentNode.Text
dr("二类") = nd.text
dr("三类") = "三类"
nd = nd.Nodes.Add("三类")
End If
tr.SelectedNode = nd
tr.Select()
tr.BeginEdit()
End If
End If