参考帮助手册写的代码
Dim it As Winform.StripItem = Forms("窗口").Strips("状态栏").Items("Total")
Dim t As Table = e.Table
it.Text = ""
If t.Cols(t.ColSel).IsNumeric Then '如果当前列是数值列
it.Text = "合计: " & t.Aggregate(AggregateEnum.Sum, t.TopRow, t.ColSel, t.BottomRow, t.ColSel)
End If
正常窗口表里执行正常
但是如果窗口表是做了折叠显示的时候,鼠标选择父级单元格的时候,合计数据会把下级的数据也统计进来。
请教,如何调整代码,只把鼠标选到的单元格数据合计?
Dim it As Winform.StripItem = Forms("窗口").Strips("状态栏").Items("Total")
Dim t As Table = e.Table
it.Text = ""
If t.Cols(t.ColSel).IsNumeric Then '如果当前列是数值列
dim sum as double
for i as integer = t.TopRow to t.BottomRow
if t.rows(i).visible then
sum += t.rows(i)(t.ColSel)
end if
it.Text = "合计: " & sum
End If