--
好吧。红袍老师,我是参考用你的那个数字级码生成的示例来做了一个生成主管司法局窗口。要达到如图所示的效果
此主题相关图片如下:qq图片20160627160517.png
如何修改那个保存到表的代码:
Dim dt As DataTable = DataTables("主管司法局")
dt.DataRows.Clear
Dim dic As New Dictionary(of Integer, Integer)
Dim prevLevel As Integer = 0
For Each nd As WinForm.TreeNode In e.Form.Controls("TreeView1").AllNodes
If nd.Level = 0 AndAlso dic.count > 0 Then
Dim temp = dic(0)
dic.Clear
dic.Add(0, temp)
End If
If dic.ContainsKey(nd.Level) = False Then
dic.Add(nd.Level, 1)
Else
dic(nd.Level) = dic(nd.Level) + 1
End If
For i As Integer = nd.level + 1 To prevLevel
dic(i) = 0
Next
prevLevel = nd.Level
Dim ndr As DataRow = dt.AddNew
Dim str As String = ""
For i As Integer = 0 To nd.Level
str &= dic(i) & "\\"
Next
ndr("编号") = str.TrimEnd("\\")
ndr("主管司法局") = nd.Text
Next
dt.Save
e.Form.Close