我现在rom表用两个主表和明细表构成,现在想用递归生成目录树展示产品目录总是不成功,直接崩溃退出系统,不知道代码怎样改?
函数代码:Dim nd As WinForm.TreeNode = args(0)
Dim dt As DataTable = args(1)
Dim drs As List(of DataRow)
drs= dt.Select("[父件编码] = '" & nd.name & "'")
For Each dr As DataRow In drs
Dim cd As Winform.TreeNode = nd.Nodes.Add(dr("子件编码"),dr("子件编码") & " " & dr("子件名称"))
Functions.Execute("产品结构目录树函数",cd,dt)
Next
生成代码:'Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
'Dim nd As WinForm.TreeNode
'Dim dt As DataTable = DataTables("产品结构")
'Dim dt1 As DataTable = DataTables("结构主表")
'tr.StopRedraw()
'tr.Nodes.Clear
'tr.Nodes.Add("全部显示")
'For Each da As DataRow In dt1.DataRows
'If da("是否最终产品") = True Then
'nd = tr.Nodes.Add(da("物料编码"),da("物料编码") & " " & da("物料名称") & " " & da("物料规格"))
'Functions.Execute("产品结构目录树函数",nd,dt)
'End If
'
'Next
'tr.ResumeRedraw()