以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 如何统计目录树各节点数据 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=79201) |
-- 作者:llh0824 -- 发布时间:2015/12/26 8:48:00 -- 如何统计目录树各节点数据 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 遍历好像不对,请教如何修改,能正确显示目录树统计数据
|
-- 作者:Hyphen -- 发布时间:2015/12/26 10:08:00 -- 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 |
-- 作者:llh0824 -- 发布时间:2015/12/26 10:41:00 -- 实现了,谢谢 |