以下代码与帮助文件中的代码完全一致,数据有3万多行,加载窗口要3分多钟,求大师指点。
Dim t As WinForm.Table = e.Form.Controls("水")
t.BackColor
= Color.LightCyan
DataTables("员工家庭").SysStyles("EmptyArea").BackColor = Color.lightcyan
'生成统计表
Dim dt As DataTable
Dim b As New sqlGroupTableBuilder("total","员工家庭")
b.ConnectionName
= "HaiHeBase"
b.Groups.AddDef("饮用水")
b.Groups.AddDef("部门村居")
b.Groups.AddDef("所站办组")
b.Groups.AddDef("户主姓名")
b.Totals.AddDef("饮用水",AggregateEnum.count,"结构") '根据客户列来统计结构数
dt = b.Build '参数设置为False,生成一个临时表,不在主界面显示
msgbox(1)
'然后根据统计表生成目录树
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt,"饮用水|部门村居|所站办组|户主姓名")
trv.StopRedraw
For Each nd As WinForm.TreeNode In trv.AllNodes
Dim bm As String = nd.DataRow("部门村居")
Dim sz As String = nd.DataRow("所站办组")
Dim aq As String = nd.DataRow("饮用水")
Dim xm As String = nd.DataRow("户主姓名")
Select Case nd.Level
Case 0
nd.Text = nd.text & "("
& dt.Compute("count(结构)","饮用水 = '" & aq & "'")
& "户)"
Case 1
nd.Text = nd.text & "("
& dt.Compute("count(结构)","饮用水 = '" & aq & "' and 部门村居 = '"
& bm & "'") & "户)"
Case 2
nd.Text = nd.text & "("
& dt.Compute("count(结构)","饮用水 = '" & aq & "' and 部门村居 = '"
& bm & "' And 所站办组 = '" & sz & "'")
& "户)"
Case 3
nd.Text = nd.text & "("
& dt.Compute("count(结构)","饮用水 = '" & aq & "' and 部门村居 = '"
& bm & "' And 所站办组 = '" & sz & "' And 户主姓名 = '" & xm & "'")
& "户)"
End Select
Next
trv.Nodes.Insert("全镇户数","全镇户数("
& dt.Compute("count(结构)")
& "户)",0)
trv.ResumeRedraw