Dim dt As DataTable
Dim b As New GroupTableBuilder("统计表1",DataTables("房间信息"))
b.Groups.AddDef("地点")
b.Groups.AddDef("楼层")
b.Groups.AddDef("房号")
b.Totals.AddDef("房号",AggregateEnum.count,"房间数") '根据房号列来统计记录数,也就是房间数
dt = b.Build(False) '参数设置为False,生成一个临时表,不在主界面显示
'然后根据统计表生成目录树
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree("房间信息", "地点|楼层",,"房号")
trv.StopRedraw
For Each nd As WinForm.TreeNode In trv.AllNodes
Dim dd As String = nd.DataRow("地点")
Dim lc As String = nd.DataRow("楼层")
Select Case nd.Level
Case 0
nd.Text = "(" & dt.Compute("count(房号)","地点 = " & dd) & "间)"
Case 1
nd.Text = "(" & dt.Compute("count(房号)","地点 = " & dd & "and 楼层 = " & lc) & "间)"
Case 2
nd.Text = nd.text & "(" & nd.DataRow("房号") & "间)"
End Select
Next
trv.Nodes.Insert("显示所有行","显示所有行(" & dt.Compute("count(房号)") & "间)",0)
trv.ResumeRedraw
遍历好像不对,请教如何修改,能正确显示目录树统计数据