以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  如何自动汇总选中的单元格的数值  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=69400)

--  作者:atmetmicoo
--  发布时间:2015/6/4 15:22:00
--  如何自动汇总选中的单元格的数值
各位狐师,

请教,我需要做到这个效果:

如果选择的单元格的列为数值类型;则自动计入数值之和,然后把这些数值和的数据显示在状态栏,如果我想在全局表内些这段代码该如何写,谢谢。

--  作者:Bin
--  发布时间:2015/6/4 15:24:00
--  
本来就有这个功能的哦.http://www.foxtable.com/help/topics/2170.htm
--  作者:atmetmicoo
--  发布时间:2015/6/4 15:45:00
--  
Bin老师

这个功能只有在打开系统菜单的时候才会显示,如果我设计了自定义菜单,不会显示自动计数效果,如下图


图片点击可在新窗口打开查看此主题相关图片如下:可以自动显示计数
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:不能自动显示计数
图片点击可在新窗口打开查看


--  作者:大红袍
--  发布时间:2015/6/4 15:46:00
--  

 参考例子

 

 下载信息  [文件大小:292.0 KB  下载次数:35]
图片点击可在新窗口打开查看点击浏览该文件:自动计算.table


--  作者:客人
--  发布时间:2015/6/4 16:52:00
--  
已解决,我在全局表AfterSelRangeChange事件中添加了代码,谢谢老师指点

Dim str1 As String = ""
Dim t As Table = CurrentTable

    Str1 = Str1 & "计数:" & t.Aggregate(AggregateEnum.Count, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " " 
    Str1 = Str1 & "累计:" & t.Aggregate(AggregateEnum.Sum, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
    Str1 = Str1 & "平均:" & t.Aggregate(AggregateEnum.Average, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
    Str1 = Str1 & "最大:" & t.Aggregate(AggregateEnum.Max, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
    Str1 = Str1 & "最小:" & t.Aggregate(AggregateEnum.Min, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
    Str1 = Str1 & "标准差:" & t.Aggregate(AggregateEnum.Std, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
    Str1 = Str1 & "总体标准差:" & t.Aggregate(AggregateEnum.StdPop, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
    Str1 = Str1 & "方差:" & t.Aggregate(AggregateEnum.Var, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
    Str1 = Str1 & "总体方差:" & t.Aggregate(AggregateEnum.VarPop, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
    RibbonMenu.StatusBar.Message3 = Str1