以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  自动计算和记录窗口的问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=99453)

--  作者:Zhao2006
--  发布时间:2017/4/19 15:36:00
--  自动计算和记录窗口的问题
蓝、色俩老师好!

两问题:1、杂项中的“自动计算”按示例的实战菜单中做了但就是没见动静。

           计算图示命令:RaiseSystemEventCurrentTable,SystemEventTypeEnum.AfterSelRangeChange)
           单元数:RaiseSystemEvent(CurrentTable,SystemEventTypeEnum.AfterSelRangeChange)       
            。。。。。。
2、系统配置栏中的“记录窗口”如何加入项目的配置栏中(即代码)?网上交流他们的问题可深奥了。。  
[此贴子已经被作者于2017/4/19 15:36:57编辑过]

--  作者:Zhao2006
--  发布时间:2017/4/19 15:45:00
--  
上传的图片附件咋就是
图片点击可在新窗口打开查看此主题相关图片如下:计算.jpg
图片点击可在新窗口打开查看
不见呢?再传一次。。
--  作者:有点色
--  发布时间:2017/4/19 15:46:00
--  

1、你去看看人家主菜单SystemIdle和AfterSelRangeChange事件的代码

 

2、直接把代码拷贝过来即可。


--  作者:Zhao2006
--  发布时间:2017/4/19 16:26:00
--  
收到,谢色老师,示例菜单的SystemIdle中有乱七八糟的东西,不删嘛就死机,把没用的删了嘛运行到计数的这地方又有提示错误的,



If CurrentTable Is Nothing Then
    Return
End If



\'以下代码用于更新配置栏"查阅模式"按钮的状态,如果按钮已经改名或者移到别的功能区,请对应地修改此段代码
\'如果删除此按钮,也应该删除此段代码
Static bm As RibbonMenu.ToggleButton
If bm Is Nothing Then
    bm = Ctype(ConfigBar.Items("BrowseMode"),RibbonMenu.ToggleButton)
End If
If DataTables.AllowEdit Then
    If bm.Pressed Then bm.Pressed = False
Else
   If bm.Pressed =False Then bm.Pressed = True
End If



\'以下代码用于在状态栏显示自动计算结果,如果不需要自动计算,可删除这一段
If Vars("SysUpdateAggregate") 
    If Windows.Forms.Control.MouseButtons <> Windows.Forms.MouseButtons.None OrElse Windows.Forms.Control.ModifierKeys <> Windows.Forms.Keys.None Then
        Return
    End If
    Dim Str1 As String = ""
    Vars("SysUpdateAggregate") = False
    With RibbonTabs("Other").Groups("Aggregate")
        With CType(.Items("Aggregate"), RibbonMenu.ToggleButton)
            If .Pressed = False Then
                Return
            End If
        End With
        If CType(.Items("Count"), RibbonMenu.CheckBox).Checked Then
            Str1 = Str1 & "计数:" & t.Aggregate(AggregateEnum.Count, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
        End If
        If CType(.Items("Sum"), RibbonMenu.CheckBox).Checked Then
            Str1 = Str1 & "累计:" & t.Aggregate(AggregateEnum.Sum, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
        End If
        If CType(.Items("Average"), RibbonMenu.CheckBox).Checked Then
            Str1 = Str1 & "平均:" & t.Aggregate(AggregateEnum.Average, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
        End If
        If CType(.Items("Max"), RibbonMenu.CheckBox).Checked Then
            Str1 = Str1 & "最大:" & t.Aggregate(AggregateEnum.Max, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
        End If
        If CType(.Items("Min"), RibbonMenu.CheckBox).Checked Then
            Str1 = Str1 & "最小:" & t.Aggregate(AggregateEnum.Min, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
        End If
        With CType(.Items("Other"), RibbonMenu.MenuButton)
            If CType(.Items("Std"), RibbonMenu.ToggleButton).Pressed Then
                Str1 = Str1 & "标准差:" & t.Aggregate(AggregateEnum.Std, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
            End If
            If CType(.Items("StdPop"), RibbonMenu.ToggleButton).Pressed Then
                Str1 = Str1 & "总体标准差:" & t.Aggregate(AggregateEnum.StdPop, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
            End If
            If CType(.Items("Var"), RibbonMenu.ToggleButton).Pressed Then
                Str1 = Str1 & "方差:" & t.Aggregate(AggregateEnum.Var, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
            End If
            If CType(.Items("VarPop"), RibbonMenu.ToggleButton).Pressed Then
                Str1 = Str1 & "总体方差:" & t.Aggregate(AggregateEnum.VarPop, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
            End If
        End With
    End With
    RibbonMenu.StatusBar.Message3 = Str1
End If

--  作者:Zhao2006
--  发布时间:2017/4/19 16:27:00
--  
提示东西。
图片点击可在新窗口打开查看此主题相关图片如下:错误提示.jpg
图片点击可在新窗口打开查看

--  作者:有点色
--  发布时间:2017/4/19 16:29:00
--  

直接写代码

 

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) & " "


StatusBar.Message3 = str1


--  作者:有点色
--  发布时间:2017/4/19 16:31:00
--  

 或者

 

Dim str1 As String = ""
Dim t As Table = CurrentTable
Dim hadString As Boolean = False
For i As Integer = t.LeftCol To t.RightCol
    If t.cols(i).IsString Then
        hadString = True
        Exit For
    End If
Next
Str1 = Str1 & "计数:" & t.Aggregate(AggregateEnum.Count, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
If hadString = False Then
    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) & " "
End If

StatusBar.Message3 = str1


--  作者:Zhao2006
--  发布时间:2017/4/19 16:35:00
--  
呵呵,还是色老师这招厉害!结果真的出来了,但这时是全部出来了,你不勾它都出来的摆在下栏那里,谢色老师了。
--  作者:有点色
--  发布时间:2017/4/19 16:46:00
--  

Dim str1 As String = ""
Dim t As Table = CurrentTable
With RibbonTabs("Other").Groups("Aggregate")
    With CType(.Items("Aggregate"), RibbonMenu.ToggleButton)
        If .Pressed = False Then
           \' Return
        End If
    End With
    If CType(.Items("Count"), RibbonMenu.CheckBox).Checked Then
        Str1 = Str1 & "计数:" & t.Aggregate(AggregateEnum.Count, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
    End If
    If CType(.Items("Sum"), RibbonMenu.CheckBox).Checked Then
        Str1 = Str1 & "累计:" & t.Aggregate(AggregateEnum.Sum, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
    End If
    If CType(.Items("Average"), RibbonMenu.CheckBox).Checked Then
        Str1 = Str1 & "平均:" & t.Aggregate(AggregateEnum.Average, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
    End If
    If CType(.Items("Max"), RibbonMenu.CheckBox).Checked Then
        Str1 = Str1 & "最大:" & t.Aggregate(AggregateEnum.Max, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
    End If
    If CType(.Items("Min"), RibbonMenu.CheckBox).Checked Then
        Str1 = Str1 & "最小:" & t.Aggregate(AggregateEnum.Min, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
    End If
    With CType(.Items("Other"), RibbonMenu.MenuButton)
        If CType(.Items("Std"), RibbonMenu.ToggleButton).Pressed Then
            Str1 = Str1 & "标准差:" & t.Aggregate(AggregateEnum.Std, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
        End If
        If CType(.Items("StdPop"), RibbonMenu.ToggleButton).Pressed Then
            Str1 = Str1 & "总体标准差:" & t.Aggregate(AggregateEnum.StdPop, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
        End If
        If CType(.Items("Var"), RibbonMenu.ToggleButton).Pressed Then
            Str1 = Str1 & "方差:" & t.Aggregate(AggregateEnum.Var, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
        End If
        If CType(.Items("VarPop"), RibbonMenu.ToggleButton).Pressed Then
            Str1 = Str1 & "总体方差:" & t.Aggregate(AggregateEnum.VarPop, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
        End If
    End With
End With

StatusBar.Message3 = str1


--  作者:Zhao2006
--  发布时间:2017/4/19 16:47:00
--  
不选勾它6、7个数也摆在下栏给你出来完的,把“自动计算”按键按上来都没有作用的,数值照列无误的了。
图片点击可在新窗口打开查看此主题相关图片如下:问题2.jpg
图片点击可在新窗口打开查看