以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  通过目录树返回项目中所有表名称及表中的所有列  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=29773)

--  作者:kevin
--  发布时间:2013/3/13 11:51:00
--  通过目录树返回项目中所有表名称及表中的所有列
请问:如何通过目录树返回项目中所有表名称及表中的所有列
--  作者:狐狸爸爸
--  发布时间:2013/3/13 11:57:00
--  

其实很简单:

 

Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
For Each dt As DataTable In DataTables
    Dim nd As WinForm.TreeNode = trv.Nodes.Add(dt.name)
    For Each dc As DataCol In dt.DataCols
        nd.Nodes.Add(dc.name)
    Next
Next


--  作者:kevin
--  发布时间:2013/3/13 12:49:00
--  
非常感谢您的帮助.

Dim tr As WinForm.TreeView
Dim nd As WinForm.TreeNode
tr = Forms("窗口1").Controls("TreeView1")
For Each tab As Table In Tables
    nd = Tr.Nodes.Add(tab.Name,tab.Name)
    For Each c As Col In Tables(tab.Name).Cols
        nd.Nodes.Add(c.Name,c.Name)
    Next
Next


能否再加个条件:不返回隐藏的列名称.能否做到?

有时候我是通过Tables("表A").Cols("客户编号").Visible = False这个代码隐藏了一些列.


--  作者:狐狸爸爸
--  发布时间:2013/3/13 14:10:00
--  

Dim tr As WinForm.TreeView
Dim nd As WinForm.TreeNode
tr = Forms("窗口1").Controls("TreeView1")
For Each tab As Table In Tables
    nd = Tr.Nodes.Add(tab.Name,tab.Name)
    For Each c As Col In Tables(tab.Name).Cols
        If c.Visible Then
            nd.Nodes.Add(c.Name,c.Name)
        End If
    Next
Next