Dim str() As String = {"部门","性别"} '定义筛选树中显示的列名
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.Nodes.Insert("显示所有行",0)
For Each c As String In str
Dim n As WinForm.TreeNode = trv.Nodes.Add(c,c)
For Each c2 As String In DataTables("表A").GetValues(c,c & " is not null")
'n.Nodes.Add(c2,c2)
n.Nodes.Add(c2,c2 & "(" & DataTables("表A").Compute("count(部门)",c & "='" & c2 & "'") & "人)")
Next
Next
Dim n2 As WinForm.TreeNode = trv.Nodes.Add("出生日期","出生日期")
For Each c2 As String In DataTables("表A").SQLGetValues("year(出生日期)","出生日期 Is not null")
Dim y As Date = new Date(cint(c2),1,1)
n2.Nodes.Add(c2,c2 & "(" & DataTables("表A").Compute("count(出生日期)","出生日期>=#" & y & "# and 出生日期 < #" & y.AddYears(1) & "#") & "人)")
Next
查询
Dim Filter As String
Dim d1 As String
'Dim dr As DataRow = e.Node.DataRow '获取生成此节点的行
Select Case e.Node.Level
Case 1
If e.Node.ParentNode.Text = "出生日期" Then
Dim y As Date = new Date(cint(e.Node.Text.Split("(")(0)),1,1)
Filter = "出生日期 >= #" & y & "# and 出生日期 < #" & y.AddYears(1) & "#"
Else
Filter = e.Node.ParentNode.Text & " = '" & e.Node.Text.Split("(")(0) & "'"
End If
End Select
Tables("表A").Filter = Filter