e.Form.DisableXButton
Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
tr.BuildTree("B_Bu", "部门|单位")
Dim Trv As WinForm.TreeView = e.Form.Controls("TreeView1")
For Each nd As WinForm.TreeNode In trv.AllNodes '遍历所有节点
nd.Text = nd.text & "|" & nd.DataRow("单位代码")
Next
打开窗口如以下:
此主题相关图片如下:3.png
增加单位的代码:
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 = 1 Then
MessageBox.Show("最多允许2层节点!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
Dim dr As DataRow = DataTables("B_Bu").AddNew
If nd.Level = 0 Then
dr("部门") = nd.Text
dr("单位") = "新单位"
End If
nd = nd.Nodes.Add("新单位")
tr.SelectedNode = nd
tr.Select()
tr.BeginEdit()
End If
End If
发现以上的代码在新增的时候会在输入的内容增加一条|线
此主题相关图片如下:5.png
[此贴子已经被作者于2016/12/7 12:08:13编辑过]