一个按钮的功能是增加或撤销分组统计按钮键。初始置<增加组计>,按选之后变为<删除统计>,往复使用。程序如下。问题是发现t.SubtotalGroups.Clear()语句不好使,什么原因呢?
Static Val As Integer
Dim zc As String
Dim b1 As WinForm.Button = e.Form.Controls("Button1")
Dim b4 As WinForm.Button = e.Form.Controls("Button4")
Dim t As Table = Tables(e.Form.name & "_Table1")
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
'定义客户分组
If val=0 Then
b4.Text="删除统计"
b1.Enabled=False
zc="合同数量吨_小计,合同数量吨_已经执行,合同数量吨_未执行,金额元_小计,金额元_累计付款,金额元_应付款," ',"
zc=zc & "发车辆_应派车数,发车辆_实派车数,发车辆_到港车数,到港数量吨,已转储备数量吨,应转储备数量吨,"
zc=zc & "中转装船数量吨,轮换数量吨,异地库存吨,港内库存吨,前日收购数吨"
g = New Subtotalgroup '定义一个新的分组
g.Aggregate = AggregateEnum.Sum '统计类型为求和
g.GroupOn = "性质" '分组列为客户
g.TotalOn =zc
g.Caption = "{0} 小计" '设置标题
t.SubtotalGroups.Add(g) '加到分组集合中
'定义产品分组
g = New Subtotalgroup
g = New Subtotalgroup '定义一个新的分组
g.Aggregate = AggregateEnum.Sum '统计类型为求和
g.GroupOn = "*" '分组列为客户
g.TotalOn =zc
g.Caption = "{0} 总计" '设置标题
t.SubtotalGroups.Add(g) '加到分组集
t.Subtotal()
val=1
Else
val=0
‘ t.SubtotalGroups.Clear()
b4.Text="增加统计"
b1.Enabled=True
End If