改一下代码
Dim nian As WinForm.ComboBox = e.Form.Controls("ComboBox1")
If nian.Value = "全部" Then
Dim g2 As New GroupTableBuilder("统计表2", DataTables("表A"))
g2.Groups.AddDef("日期", DateGroupEnum.Year, "年")
g2.Totals.AddDef("编号", AggregateEnum.Count, "数量")
Tables("统计_Table1").DataSource = g2.BuildDataSource
Tables("统计_Table1").font = New Font("宋体", 12)
DataTables("统计_Table1").SysStyles("Alternate").BackColor = Color.LightCyan '设置交替行颜色
DataTables("统计_Table1").SysStyles("EmptyArea").BackColor = Color.LightBLue '设置空白区域颜色
Else
Dim dt As Date = new Date(nian.value, 1, 1) '定义选择年度的第1天
Dim g2 As New GroupTableBuilder("统计表2", DataTables("表A"))
g2.Filter = "日期 >= '" & dt & "' And 日期 < '" & dt.addyears(1) & "' "
g2.Groups.AddDef("日期", DateGroupEnum.Year, "年")
g2.Totals.AddDef("编号", AggregateEnum.Count, "数量")
Tables("统计_Table1").DataSource = g2.BuildDataSource
Tables("统计_Table1").font = New Font("宋体", 12)
DataTables("统计_Table1").SysStyles("Alternate").BackColor = Color.LightCyan '设置交替行颜色
DataTables("统计_Table1").SysStyles("EmptyArea").BackColor = Color.LightBLue '设置空白区域颜色
End If