窗口添加一个按钮,把代码放到窗口按钮里,不要放到表事件。然后后面代码改为
……
Dim b As New GroupTableBuilder("后果ID", DataTables("HAZOP"))
b.Groups.AddDef("后果主题ID") '根据后果主题ID分组
b.Totals.AddDef("后果主题ID", AggregateEnum.Count, "出现次数")
b.filter = Tables("HAZOP").filter
Dim Cols1() As String = {"后果主题ID", "出现次数"}
Dim Cols2() As String = {"后果主题ID", "出现次数"}
For Each r1 As dataRow In dt .datarows
Dim r2 As Row = Tables("后果ID统计").AddNew()
For i As Integer = 0 To Cols1.Length - 1
r2(Cols2(i)) = r1(Cols1(i))
Next
Next