Foxtable(狐表)用户栏目专家坐堂 → 如何根据表的某列生成目录树的问题


  共有5182人关注过本帖平板打印复制链接

主题:如何根据表的某列生成目录树的问题

帅哥哟,离线,有人找我吗?
lsy
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:5246 积分:33163 威望:0 精华:8 注册:2013/1/17 21:28:00
  发帖心情 Post By:2014/8/11 18:09:00 [只看该作者]

不需要递归,也不需要判断规则:

Dim tv As WinForm.TreeView = e.Form.Controls("TreeView科目表")
tv.StopRedraw
Dim t As Table = Tables("科目表")
t.Sort = "科目代码"
Dim lst As New List(Of Integer)
For Each r As Row In t.Rows
    If lst.Contains(r("科目代码").Length) = False Then
        lst.Add(r("科目代码").Length)
    End If
Next
lst.Sort
tv.Nodes.Clear
For Each r As Row In t.Rows
    If tv.Nodes.Contains(r("科目代码")) = False Then
        tv.Nodes.Add(r("科目代码"),r("科目名称"))
    End If
Next
For Each nd As WinForm.TreeNode In tv.AllNodes
    For i As Integer = 1 To lst.Count - 1
        If nd.Name.Length = lst(i) Then           
            For j As Integer = 0 To i - 1
                nd.MoveRight
            Next
        End If
    Next
Next
tv.CollapseAll
tv.ResumeRedraw

[此贴子已经被作者于2014-8-11 18:10:58编辑过]

 回到顶部
总数 35 1 2 3 4 下一页