afterload加入代码,至于筛选,你参考帮助文档做一下
'首先生成统计表
Dim dt As DataTable
Dim b As New GroupTableBuilder("统计表1",DataTables("表A"))
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(dt, "车间|科室")
trv.StopRedraw
For Each nd As WinForm.TreeNode In trv.AllNodes
Dim cj As String = nd.DataRow("车间")
Dim ks As String = nd.DataRow("科室")
Select Case nd.Level
Case 0
nd.Text = nd.text & "(" & dt.Compute("Sum(人数)","车间 = '" & cj & "'") & "条)"
Case 1
nd.Text = nd.text & "(" & dt.Compute("Sum(人数)","车间 = '" & cj & "' And 科室 = '" & ks & "'") & "条)"
End Select
Next
trv.Nodes.Insert("显示所有行","显示所有行(" & dt.Compute("Sum(人数)") & "条)",0)
trv.ResumeRedraw