以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]这个目录树怎样写代码  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=39716)

--  作者:ybmjy
--  发布时间:2013/8/30 22:09:00
--  [求助]这个目录树怎样写代码


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20130830220426.png
图片点击可在新窗口打开查看


 


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20130830220412.png
图片点击可在新窗口打开查看

 

 

Dim tr As WinForm.TreeView
Dim nd As WinForm.TreeNode
Dim md As WinForm.TreeNode
tr = Forms("窗口1").Controls("TreeView1")
nd = Tr.Nodes.Add("目录","目录")
Dim ss As String = DataTables("表A").GetComboListString("第三列","[第三列] Is Not Null")
Dim aValues() As String
aValues =ss.split("|")
For Each valu As String In avalues
    Dim r1 As String
    r1= valu
    md=nd.Nodes.Add(r1,r1) 
    Dim s As String = DataTables("表A").GetComboListString("第一列","[第一列] Is Not Null")
    Dim Values() As String
    Values =s.split("|")
    For Each value As String In values
        Dim v1 As String
        v1= "【" & value & "】"
        Dim dr As DataRow = DataTables("表A").Find("[第一列] = \'" & value & "\'")
        Dim v2 As String = dr("第二列")
        md.Nodes.Add(v1 & v2,v1 & v2)
    Next
Next
 

 

 

上述代码错在哪,请高手指点

上述代码生成的是这个样的


 


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20130830221158.png
图片点击可在新窗口打开查看
[此贴子已经被作者于2013-8-30 22:13:12编辑过]

--  作者:有点甜
--  发布时间:2013/8/30 22:24:00
--  
参考下面的代码,测试有效。

Dim trv As WinForm.TreeView = Forms("窗口1").Controls("TreeView1")
Dim dt As DataTable = DataTables("表B")

Dim nd As WinForm.TreeNode = Trv.Nodes.Add("目录","目录")

Dim vals As List(Of String) = dt.GetUniqueValues("[第三列] Is Not Null", "第三列")

For Each val As String In vals
    Dim md As WinForm.TreeNode = nd.Nodes.Add(val, val)  
    Dim arys As List(Of String()) = dt.GetUniqueValues("第三列 = \'" & val & "\'", "第一列", "第二列")
    For Each ary() As String In arys
        Dim s As String = "【" & ary(0) & "】"
        md.Nodes.Add(2 & ary(1), s & ary(1))
    Next
Next

--  作者:ybmjy
--  发布时间:2013/8/30 22:37:00
--  

谢谢你,正好