-- 作者:mr725
-- 发布时间:2010/1/8 21:41:00
--
俺把代码贴出来吧:
Dim dl as string = "产品|客户|雇员" Dim tr As WinForm.TreeView Dim nd,nd1,nd2,nd3 As WinForm.TreeNode tr = e.Form.Controls("TreeView1") \'Forms("窗口1").Controls("TreeView1") tr.Nodes.Clear for i as integer = 0 to dl.split("|").length-1 nd = Tr.Nodes.Add("Root & i","按" & "" & dl.split("|")(i) & "") Dim pcas As List(Of String) pcas = DataTables("订单").GetUniqueValues("", "" & dl.split("|")(i) & "") For ii As integer = 0 to pcas.count-1 nd1 = nd.Nodes.Add("Sub & ii+1","" & pcas(ii) & "") if i+1<=dl.split("|").length-1 dim f as string = "[" & dl.split("|")(i) & "] = \'" & nd1.text & "\' " Dim cas As List(Of String) = DataTables("订单").GetUniqueValues( f ,"" & dl.split("|")(i+1) & "") for iii as integer = 0 to cas.count-1 nd2 = nd1.Nodes.Add("Sub & iii+1","" & cas(iii) & "") if i+2=dl.split("|").length-1 dim f1 as string = "[" & dl.split("|")(i+1) & "] = \'" & nd2.text & "\'" Dim ca As List(Of String) = DataTables("订单").GetUniqueValues(f & "and " & f1 ,"" & dl.split("|")(i+2) & "") for iiii as integer = 0 to ca.count-1 nd3 = nd2.Nodes.Add("Sub & iiii+1","" & ca(iiii) & "") next end if if i+2-dl.split("|").length+1 = 1 dim f1 as string = "[" & dl.split("|")(i+1) & "] = \'" & nd2.text & "\'" Dim ca As List(Of String) = DataTables("订单").GetUniqueValues(f & "and " & f1 ,"" & dl.split("|")(0) & "") for iiii as integer = 0 to ca.count-1 nd3 = nd2.Nodes.Add("Sub & iiii+1","" & ca(iiii) & "") next end if next else dim f as string = "[" & dl.split("|")(i) & "] = \'" & nd1.text & "\' " Dim cas As List(Of String) = DataTables("订单").GetUniqueValues(f ,"" & dl.split("|")(0) & "") for iii as integer = 0 to cas.count-1 nd2 = nd1.Nodes.Add("Sub & iii+1","" & cas(iii) & "") dim f1 as string = "[" & dl.split("|")(0) & "] = \'" & nd2.text & "\'" if i+2-dl.split("|").length-1 = 0 Dim ca As List(Of String) = DataTables("订单").GetUniqueValues(f & "and " & f1 ,"" & dl.split("|")(1) & "") for iiii as integer = 0 to ca.count-1 nd3 = nd2.Nodes.Add("Sub & iiii+1","" & ca(iiii) & "") next end if next end if Next next
总觉得很繁琐,应该可以简化的,可是俺功底不足, 看看其他前辈和狐友的了。
|