函数是用的nd.name:
Dim nd As WinForm.TreeNode = args(0)
Dim dt As DataTable = args(1)
Dim drs As List(of DataRow)
drs = dt.Select("[父件编码] = '" & nd.name & "' and 工序号 is null")
For Each dr As DataRow In drs
Dim cd As Winform.TreeNode = nd.Nodes.Add(dr("产品编码"),dr("产品编码") & "|" & dr("品名"))
Functions.Execute("AddChildren_MPS",cd,dt)
Next
现在情况是如果顶层编号设置在第1层以后都可以正确生成目录树,而在0层时只用一列生成目录树就出错,是不是最后那段哪里写错了。谢谢!
'生成目录树
Select Case Cmb1
Case "订单编号"
tr.Nodes.Clear '清空当前目录树
tr.buildtree(e.Form.name & "_明细","订单编号|顶层编码")
tr.Nodes.Insert("显示所有",0) '最顶端显示
tr.StopRedraw()
For Each nd As WinForm.treeNode In tr.AllNodes
If nd.Level = 1 Then
nd.text = nd.text & "|" & nd.DataRow("品名")
Functions.Execute("AddChildren_MPS",nd,dt)
End If
Next
tr.ResumeRedraw()
Case "客户"
tr.Nodes.Clear '清空当前目录树
tr.buildtree(e.Form.name & "_明细","客户|订单编号|顶层编码")
tr.Nodes.Insert("显示所有",0) '最顶端显示
tr.StopRedraw()
For Each nd As WinForm.treeNode In tr.AllNodes
If nd.Level = 2 Then
nd.text = nd.text & "|" & nd.DataRow("品名")
Functions.Execute("AddChildren_MPS",nd,dt)
End If
Next
tr.ResumeRedraw()
Case "产品编码"
tr.Nodes.Clear '清空当前目录树
tr.buildtree(e.Form.name & "_明细","顶层编码")
tr.Nodes.Insert("显示所有",0) '最顶端显示
tr.StopRedraw()
For Each nd As WinForm.treeNode In tr.AllNodes
If nd.Level = 0 Then
nd.text = nd.text & "|" & nd.DataRow("品名")
Functions.Execute("AddChildren_MPS",nd,dt)
End If
Next
tr.ResumeRedraw()
End Select