以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]统计目录树  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=174075)

--  作者:2425004926
--  发布时间:2021/12/30 15:17:00
--  [求助]统计目录树
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

\'首先生成统计表
Dim
dt As DataTable
Dim
b As New GroupTableBuilder("统计表1",DataTables("订单"))
b
.Groups.AddDef("日期",DateGroupEnum.Year,"年")
b
.Groups.AddDef("日期",DateGroupEnum.Month,"")
b
.Groups.AddDef("产品")
b
.Totals.AddDef("客户",AggregateEnum.Count,"订单数") \'根据客户列来统计记录数,也就是订单数
dt
= b.Build(True) \'参数设置为True,生成一个临时表,不在主界面显示
\'然后根据统计表生成目录树

Dim
trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv
.BuildTree(dt, "||产品")
trv
.StopRedraw
For
Each nd As WinForm.TreeNode In trv.AllNodes
   
Dim Year As Integer = nd.DataRow("")
   
Dim Month As Integer = nd.DataRow("")
   
Dim Product As String = nd.DataRow("产品")
   
Select Case nd.Level
       
Case 0
           
nd.Text = nd.text & "(" & dt.Compute("Sum(订单数)"," = " & Year) & ")"
       
Case 1
           
nd.Text = nd.text & "(" & dt.Compute("Sum(订单数)"," = " & Year & " And = " & Month) & ")"
       
Case 2
           
nd.Text = nd.text & "(" & nd.DataRow("订单数") & ")"
   
End
Select
Next

trv
.Nodes.Insert("显示所有行","显示所有行(" & dt.Compute("Sum(订单数)") & "条)",0)
trv
.ResumeRedraw

 

以上代码是统计目录树的例子,红色粗体部分怎么能用数组一级一级遍历一下,因为我将目录用变量设成了动态,层数自由设定,想改一下,还没有想出很好的方法

--  作者:有点蓝
--  发布时间:2021/12/30 15:30:00
--  
参考:http://www.foxtable.com/webhelp/topics/2503.htm
--  作者:2425004926
--  发布时间:2021/12/30 15:32:00
--  
 明白了,谢谢!