-- 发布后目录树不加载
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(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 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
上面是AFTERLOAD事件
Dim Filter As String = ""
If e.node.Name <> "显示所有行" Then \'要用Name属性,不能用Text属性
Dim d1 As Date
Dim d2 As Date
Dim Year As Integer = e.Node.DataRow("年")
Dim Month As Integer = e.Node.DataRow("月")
Dim Product As String = e.Node.DataRow("客户简称")
Select Case e.Node.Level
Case 0
d1 = New Date(Year,1,1) \'取得该年的第一天
d2 = new Date(Year,12,31) \'取得该年的最后一天
Filter = "日期 >= #" & d1 & "# And 日期 <= #" & d2 & "#"
Case 1
d1 = New Date(Year, Month, 1) \'取得该月的第一天
d2 = new Date(Year, Month, Date.DaysInMonth(Year,Month)) \'取得该月的最后一天
Filter = "日期 >= #" & d1 & "# And 日期 <= #" & d2 & "#"
Case 2
d1 = New Date(Year, Month, 1) \'取得该月的第一天
d2 = new Date(Year, Month, Date.DaysInMonth(Year,Month)) \'取得该月的最后一天
Filter = "日期 >= #" & d1 & "# And 日期 <= #" & d2 & "# And 客户简称 = \'" & Product & "\'"
End Select
End If
Tables("手册业务").Filter = Filter
这个是nodemousedoubleclik事件