Foxtable(狐表)用户栏目专家坐堂 → [求助]固定合计行抄作业出错


  共有3515人关注过本帖树形打印复制链接

主题:[求助]固定合计行抄作业出错

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/12/3 22:13:00 [显示全部帖子]

Dim sender As object = Args(0)
Dim ea As object = Args(1)
If sender.Name = "" Then Return Nothing  '没有设置好Table 和底层的关联
If Tables.Contains(sender.Name) = False Then Return Nothing  '不存在就退出
Dim tb As Table = Tables(sender.Name)
If tb.GrandTotal  Then    '如果处于合计模式
    If sender.Rows(sender.Rows.count -1).Top < sender.Height - sender.rows(sender.rows.count -1).Height * 2 Then  '如果原合计行可视
        If sender.Controls.ContainsKey("Myhuizong")  Then  '删除合计行控件
            sender.Controls.RemoveByKey("Myhuizong")
        End If
    Else
        Dim hg As Integer = sender.rows(sender.rows.count -1).Height  '控件高
        If hg = -1 Then
            hg = sender.rows(sender.rows.count -1).HeightDisplay
        End If
        Dim gh = sender.Height - 1
        If sender.ScrollBarsVisible = 1 OrElse sender.ScrollBarsVisible = 3  Then  '显示了水平滚动条
            gh = gh - 19
        End If
        If sender.Controls.ContainsKey("Myhuizong") = False Then  '不存在汇总控件,则添加
            Dim huizong As new C1.Win.C1FlexGrid.C1FlexGrid
            With huizong
                .name = "Myhuizong"
                .BorderStyle = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None '无边框
                .Cols.Count = sender.Cols.Count
                .rows.count = 2
                .Rows(0).Height = 0    '隐藏标题行
                .Enabled = False    '不能使用控件
            End With
            sender.Controls.add(huizong)   '加入控件
        End If
        Dim hui As C1.Win.C1FlexGrid.C1FlexGrid = sender.Controls("Myhuizong")
        If sender.ScrollBarsVisible = 0 OrElse sender.ScrollBarsVisible = 2  Then  '显示了垂直滚动条
            hui.ScrollBars = 2
        Else
            hui.ScrollBars = 0
        End If
        'With hui         '调整位置
        '.left = 0
        '.Top = gh - hg - 1
        '.width = sender.width -19
        '.Height = hg + 2
        '.Rows(1).Height = hg
        'End With
        With hui         '调整位置
            .left = 0
            If sender.Rows(sender.Rows.count -1).Top < sender.Height - sender.rows(sender.rows.count -1).Height * 2 Then
                .Top = sender.Rows(sender.Rows.count -1).Top  'sender.GetCellRect(sender.Rows.count-1, 1).y
            Else
                .top = gh - hg - 1
            End If
            .width = sender.width -19
            .Height = hg + 2
            .Rows(1).Height = hg
        End With
       
        Dim sLightBlue As C1.Win.C1FlexGrid.CellStyle = hui.Styles.Add("LightBlue")
        sLightBlue.BackColor = Drawing.Color.PaleGreen
        Dim i As Integer
        For i = 0 To  sender.Cols.count -1
            If sender.Cols(i).width = -1 Then    '同步列宽
                hui.Cols(i).width = sender.Cols.DefaultSize
            Else
                hui.Cols(i).width = sender.Cols(i).width
            End If
            'hui.Cols(i).Style = sender.Cols(i).Style    '同步列样式
            If i > 0 Then hui.SetCellStyle(1,i,sLightBlue)
            hui.Cols(i).Visible = sender.Cols(i).Visible   '同步隐藏列
        Next
        hui.Cols.Frozen = sender.Cols.Frozen   '同步冻结列
        hui.ScrollPosition = sender.ScrollPosition   '同步水平滚动
        For i = 1 To sender.Cols.count-1
            If hui.Cols(i).visible Then
                hui(1,i) = "合计"
                Exit For
            End If
        Next

        For i = 2  To  sender.Cols.count -1
            If tb.Cols(i-1).GrandTotal Then
                hui(1,i) = sender.Aggregate(C1.Win.C1FlexGrid.AggregateEnum.Sum,0,i,sender.Rows.count-2,i,1)
            Else
                hui(1,i) = Nothing
            End If
        Next
    End If
Else   '检查并删除控件
    If sender.Controls.ContainsKey("Myhuizong")  Then  '删除控件
        sender.Controls.RemoveByKey("Myhuizong")
    End If
End If

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/12/4 8:45:00 [显示全部帖子]

1、列宽问题

 

Dim sender As object = Args(0)
Dim ea As object = Args(1)
If sender.Name = "" Then Return Nothing  '没有设置好Table 和底层的关联
If Tables.Contains(sender.Name) = False Then Return Nothing  '不存在就退出
Dim tb As Table = Tables(sender.Name)
If tb.GrandTotal  Then    '如果处于合计模式
    If sender.Rows(sender.Rows.count -1).Top < sender.Height - sender.rows(sender.rows.count -1).Height * 2 Then  '如果原合计行可视
        If sender.Controls.ContainsKey("Myhuizong")  Then  '删除合计行控件
            sender.Controls.RemoveByKey("Myhuizong")
        End If
    Else
        Dim hg As Integer = sender.rows(sender.rows.count -1).Height  '控件高
        If hg = -1 Then
            hg = sender.rows(sender.rows.count -1).HeightDisplay
        End If
        Dim gh = sender.Height - 1
        If sender.ScrollBarsVisible = 1 OrElse sender.ScrollBarsVisible = 3  Then  '显示了水平滚动条
            gh = gh - 19
        End If
        If sender.Controls.ContainsKey("Myhuizong") = False Then  '不存在汇总控件,则添加
            Dim huizong As new C1.Win.C1FlexGrid.C1FlexGrid
            With huizong
                .name = "Myhuizong"
                .BorderStyle = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None '无边框
                .Cols.Count = sender.Cols.Count
                .rows.count = 2
                .Rows(0).Height = 0    '隐藏标题行
                .Enabled = False    '不能使用控件
            End With
            sender.Controls.add(huizong)   '加入控件
        End If
        Dim hui As C1.Win.C1FlexGrid.C1FlexGrid = sender.Controls("Myhuizong")
        If sender.ScrollBarsVisible = 0 OrElse sender.ScrollBarsVisible = 2  Then  '显示了垂直滚动条
            hui.ScrollBars = 2
        Else
            hui.ScrollBars = 0
        End If
        'With hui         '调整位置
        '.left = 0
        '.Top = gh - hg - 1
        '.width = sender.width -19
        '.Height = hg + 2
        '.Rows(1).Height = hg
        'End With
        With hui         '调整位置
            .left = 0
            If sender.Rows(sender.Rows.count -1).Top < sender.Height - sender.rows(sender.rows.count -1).Height * 2 Then
                .Top = sender.Rows(sender.Rows.count -1).Top  'sender.GetCellRect(sender.Rows.count-1, 1).y
            Else
                .top = gh - hg - 1
            End If
            .width = sender.width -19
            .Height = hg + 2
            .Rows(1).Height = hg
        End With
       
        Dim sLightBlue As C1.Win.C1FlexGrid.CellStyle = hui.Styles.Add("LightBlue")
        sLightBlue.BackColor = Drawing.Color.PaleGreen
        Dim i As Integer
        For i = 0 To  sender.Cols.count -1
            If sender.Cols(i).width = -1 Then    '同步列宽
                hui.Cols(i).width = sender.Cols.DefaultSize
            Else
                hui.Cols(i).widthdisplay = sender.Cols(i).widthdisplay
            End If
            hui.Cols(i).Style = sender.Cols(i).Style    '同步列样式
            If i > 0 Then hui.SetCellStyle(1,i,sLightBlue)
            hui.Cols(i).Visible = sender.Cols(i).Visible   '同步隐藏列
        Next
        hui.Cols.Frozen = sender.Cols.Frozen   '同步冻结列
        hui.ScrollPosition = sender.ScrollPosition   '同步水平滚动
        For i = 1 To sender.Cols.count-1
            If hui.Cols(i).visible Then
                hui(1,i) = "合计"
                Exit For
            End If
        Next
        For i = 2  To  sender.Cols.count -1
            If tb.Cols(i-1).GrandTotal Then
                hui(1,i) = sender.Aggregate(C1.Win.C1FlexGrid.AggregateEnum.Sum,0,i,sender.Rows.count-2,i,1)
            Else
                hui(1,i) = Nothing
            End If
        Next
        hui.ExtendLastCol = sender.ExtendLastCol
    End If
Else   '检查并删除控件
    If sender.Controls.ContainsKey("Myhuizong")  Then  '删除控件
        sender.Controls.RemoveByKey("Myhuizong")
    End If
End If

 

2、目录树问题,请说明如何操作有问题。我测试不出来。


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/12/4 9:29:00 [显示全部帖子]

1、逻辑列问题

 

Dim sender As object = Args(0)
Dim ea As object = Args(1)
If sender.Name = "" Then Return Nothing  '没有设置好Table 和底层的关联
If Tables.Contains(sender.Name) = False Then Return Nothing  '不存在就退出
Dim tb As Table = Tables(sender.Name)
If tb.GrandTotal  Then    '如果处于合计模式
    If sender.Rows(sender.Rows.count -1).Top < sender.Height - sender.rows(sender.rows.count -1).Height * 2 Then  '如果原合计行可视
        If sender.Controls.ContainsKey("Myhuizong")  Then  '删除合计行控件
            sender.Controls.RemoveByKey("Myhuizong")
        End If
    Else
        Dim hg As Integer = sender.rows(sender.rows.count -1).Height  '控件高
        If hg = -1 Then
            hg = sender.rows(sender.rows.count -1).HeightDisplay
        End If
        Dim gh = sender.Height - 1
        If sender.ScrollBarsVisible = 1 OrElse sender.ScrollBarsVisible = 3  Then  '显示了水平滚动条
            gh = gh - 19
        End If
        If sender.Controls.ContainsKey("Myhuizong") = False Then  '不存在汇总控件,则添加
            Dim huizong As new C1.Win.C1FlexGrid.C1FlexGrid
            With huizong
                .name = "Myhuizong"
                .BorderStyle = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None '无边框
                .Cols.Count = sender.Cols.Count
                .rows.count = 2
                .Rows(0).Height = 0    '隐藏标题行
                .Enabled = False    '不能使用控件
            End With
            sender.Controls.add(huizong)   '加入控件
        End If
        Dim hui As C1.Win.C1FlexGrid.C1FlexGrid = sender.Controls("Myhuizong")
        If sender.ScrollBarsVisible = 0 OrElse sender.ScrollBarsVisible = 2  Then  '显示了垂直滚动条
            hui.ScrollBars = 2
        Else
            hui.ScrollBars = 0
        End If
        'With hui         '调整位置
        '.left = 0
        '.Top = gh - hg - 1
        '.width = sender.width -19
        '.Height = hg + 2
        '.Rows(1).Height = hg
        'End With
        With hui         '调整位置
            .left = 0
            If sender.Rows(sender.Rows.count -1).Top < sender.Height - sender.rows(sender.rows.count -1).Height * 2 Then
                .Top = sender.Rows(sender.Rows.count -1).Top  'sender.GetCellRect(sender.Rows.count-1, 1).y
            Else
                .top = gh - hg - 1
            End If
            .width = sender.width -19
            .Height = hg + 2
            .Rows(1).Height = hg
        End With
       
        Dim sLightBlue As C1.Win.C1FlexGrid.CellStyle = hui.Styles.Add("LightBlue")
        sLightBlue.BackColor = Drawing.Color.PaleGreen
        Dim i As Integer
        Dim flag As Integer = -1
        For i = 0 To  sender.Cols.count -1
            If sender.Cols(i).width = -1 Then    '同步列宽
                hui.Cols(i).width = sender.Cols.DefaultSize
            Else
                hui.Cols(i).widthdisplay = sender.Cols(i).widthdisplay
            End If
            If i > 0 Then hui.SetCellStyle(1,i,sLightBlue)
            hui.Cols(i).Visible = sender.Cols(i).Visible   '同步隐藏列
            If sender.Cols(i).Visible AndAlso flag < 0 AndAlso i > 0 Then
                hui(1,i) = "合计"
                flag = i
            End If
            If i > flag Then
                hui.Cols(i).Style = sender.Cols(i).Style    '同步列样式
            End If
        Next
        hui.Cols.Frozen = sender.Cols.Frozen   '同步冻结列
        hui.ScrollPosition = sender.ScrollPosition   '同步水平滚动
        For i = 2  To  sender.Cols.count -1
            If tb.Cols(i-1).GrandTotal Then
                hui(1,i) = sender.Aggregate(C1.Win.C1FlexGrid.AggregateEnum.Sum,0,i,sender.Rows.count-2,i,1)
            Else
                hui(1,i) = Nothing
            End If
        Next
        hui.ExtendLastCol = sender.ExtendLastCol
    End If
Else   '检查并删除控件
    If sender.Controls.ContainsKey("Myhuizong")  Then  '删除控件
        sender.Controls.RemoveByKey("Myhuizong")
    End If
End If

 

2、选择不同的用户,其合计列,就是应该不同的啊,根据例子截图说明你的问题。


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/12/4 10:27:00 [显示全部帖子]

Dim sender As object = Args(0)
Dim ea As object = Args(1)
If sender.Name = "" Then Return Nothing  '没有设置好Table 和底层的关联
If Tables.Contains(sender.Name) = False Then Return Nothing  '不存在就退出
Dim tb As Table = Tables(sender.Name)
If tb.GrandTotal  Then    '如果处于合计模式
    'If sender.Rows(sender.Rows.count -1).Top < sender.Height - sender.rows(sender.rows.count -1).Height * 2 Then  '如果原合计行可视
        'If sender.Controls.ContainsKey("Myhuizong")  Then  '删除合计行控件
            'sender.Controls.RemoveByKey("Myhuizong")
        'End If
    'Else
        Dim hg As Integer = sender.rows(sender.rows.count -1).Height  '控件高
        If hg = -1 Then
            hg = sender.rows(sender.rows.count -1).HeightDisplay
        End If
        Dim gh = sender.Height - 1
        If sender.ScrollBarsVisible = 1 OrElse sender.ScrollBarsVisible = 3  Then  '显示了水平滚动条
            gh = gh - 19
        End If
        If sender.Controls.ContainsKey("Myhuizong") = False Then  '不存在汇总控件,则添加
            Dim huizong As new C1.Win.C1FlexGrid.C1FlexGrid
            With huizong
                .name = "Myhuizong"
                .BorderStyle = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None '无边框
                .Cols.Count = sender.Cols.Count
                .rows.count = 2
                .Rows(0).Height = 0    '隐藏标题行
                .Enabled = False    '不能使用控件
            End With
            sender.Controls.add(huizong)   '加入控件
        End If
        Dim hui As C1.Win.C1FlexGrid.C1FlexGrid = sender.Controls("Myhuizong")
        If sender.ScrollBarsVisible = 0 OrElse sender.ScrollBarsVisible = 2  Then  '显示了垂直滚动条
            hui.ScrollBars = 2
        Else
            hui.ScrollBars = 0
        End If
        'With hui         '调整位置
        '.left = 0
        '.Top = gh - hg - 1
        '.width = sender.width -19
        '.Height = hg + 2
        '.Rows(1).Height = hg
        'End With
        With hui         '调整位置
            .left = 0
            If sender.Rows(sender.Rows.count -1).Top < sender.Height - sender.rows(sender.rows.count -1).Height * 2 Then
                .Top = sender.Rows(sender.Rows.count -1).Top  'sender.GetCellRect(sender.Rows.count-1, 1).y
            Else
                .top = gh - hg - 1
            End If
            .width = sender.width -19
            .Height = hg + 2
            .Rows(1).Height = hg
        End With
       
        Dim sLightBlue As C1.Win.C1FlexGrid.CellStyle = hui.Styles.Add("LightBlue")
        sLightBlue.BackColor = Drawing.Color.PaleGreen
        Dim i As Integer
        Dim flag As Integer = -1
        For i = 0 To  sender.Cols.count -1
            If sender.Cols(i).width = -1 Then    '同步列宽
                hui.Cols(i).width = sender.Cols.DefaultSize
            Else
                hui.Cols(i).widthdisplay = sender.Cols(i).widthdisplay
            End If
            If i > 0 Then hui.SetCellStyle(1,i,sLightBlue)
            hui.Cols(i).Visible = sender.Cols(i).Visible   '同步隐藏列
            If sender.Cols(i).Visible AndAlso flag < 0 AndAlso i > 0 Then
                hui(1,i) = "合   计"
                flag = i
            End If
            If i > flag Then
                hui.Cols(i).Style = sender.Cols(i).Style    '同步列样式
            End If
        Next
        hui.Cols.Frozen = sender.Cols.Frozen   '同步冻结列
        hui.ScrollPosition = sender.ScrollPosition   '同步水平滚动
        For i = 2  To  sender.Cols.count -1
            If tb.Cols(i-1).GrandTotal Then
                hui(1,i) = sender.Aggregate(C1.Win.C1FlexGrid.AggregateEnum.Sum,0,i,sender.Rows.count-2,i,1)
            Else
                hui(1,i) = Nothing
            End If
        Next
        hui.ExtendLastCol = sender.ExtendLastCol
    'End If
Else   '检查并删除控件
    If sender.Controls.ContainsKey("Myhuizong")  Then  '删除控件
        sender.Controls.RemoveByKey("Myhuizong")
    End If
End If

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/12/4 10:47:00 [显示全部帖子]

这段代码去掉即可

 

           If i > flag Then
                hui.Cols(i).Style = sender.Cols(i).Style    '同步列样式
            End If

 


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/12/4 10:52:00 [显示全部帖子]

以下是引用Fox86在2017/12/4 10:50:00的发言:
好的。非常感谢!另外顺带问一下,系统自带的数据统计功能合计模式中能去掉逻辑列吗?

 

系统自带的不能控制。

 

必须自定义合计行,才能自由控制。


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/12/4 11:14:00 [显示全部帖子]

Dim sender As object = Args(0)
Dim ea As object = Args(1)
If sender.Name = "" Then Return Nothing  '没有设置好Table 和底层的关联
If Tables.Contains(sender.Name) = False Then Return Nothing  '不存在就退出
Dim tb As Table = Tables(sender.Name)
If tb.GrandTotal  Then    '如果处于合计模式
    'If sender.Rows(sender.Rows.count -1).Top < sender.Height - sender.rows(sender.rows.count -1).Height * 2 Then  '如果原合计行可视
    'If sender.Controls.ContainsKey("Myhuizong")  Then  '删除合计行控件
    'sender.Controls.RemoveByKey("Myhuizong")
    'End If
    'Else
    Dim hg As Integer = sender.rows(sender.rows.count -1).Height  '控件高
    If hg = -1 Then
        hg = sender.rows(sender.rows.count -1).HeightDisplay
    End If
    Dim gh = sender.Height - 1
    If sender.ScrollBarsVisible = 1 OrElse sender.ScrollBarsVisible = 3  Then  '显示了水平滚动条
        gh = gh - 19
    End If
    If sender.Controls.ContainsKey("Myhuizong") = False Then  '不存在汇总控件,则添加
        Dim huizong As new C1.Win.C1FlexGrid.C1FlexGrid
        With huizong
            .name = "Myhuizong"
            .BorderStyle = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None '无边框
            .Cols.Count = sender.Cols.Count
            .rows.count = 2
            .Rows(0).Height = 0    '隐藏标题行
            .Enabled = False    '不能使用控件
        End With
        sender.Controls.add(huizong)   '加入控件
    End If
    Dim hui As C1.Win.C1FlexGrid.C1FlexGrid = sender.Controls("Myhuizong")
    If sender.ScrollBarsVisible = 0 OrElse sender.ScrollBarsVisible = 2  Then  '显示了垂直滚动条
        hui.ScrollBars = 2
    Else
        hui.ScrollBars = 0
    End If
    'With hui         '调整位置
    '.left = 0
    '.Top = gh - hg - 1
    '.width = sender.width -19
    '.Height = hg + 2
    '.Rows(1).Height = hg
    'End With
    With hui         '调整位置
        .left = 0
        If sender.Rows(sender.Rows.count -1).Top < sender.Height - sender.rows(sender.rows.count -1).Height * 2 Then
            .Top = sender.Rows(sender.Rows.count -1).Top  'sender.GetCellRect(sender.Rows.count-1, 1).y
        Else
            .top = gh - hg - 1
        End If
        .width = sender.width -19
        .Height = hg + 2
        .Rows(1).Height = hg
    End With
   
    Dim sLightBlue As C1.Win.C1FlexGrid.CellStyle = hui.Styles.Add("LightBlue")
    sLightBlue.BackColor = Drawing.Color.PaleGreen
    Dim i As Integer
    Dim flag As Integer = -1
    For i = 0 To  sender.Cols.count -1
        If sender.Cols(i).width = -1 Then    '同步列宽
            hui.Cols(i).width = sender.Cols.DefaultSize
        Else
            hui.Cols(i).widthdisplay = sender.Cols(i).widthdisplay
        End If
        If i > 0 Then hui.SetCellStyle(1,i,sLightBlue)
        hui.Cols(i).Visible = sender.Cols(i).Visible   '同步隐藏列
        If sender.Cols(i).Visible AndAlso flag < 0 AndAlso i > 0 Then
            hui(1,i) = "合   计"
            flag = i
        End If
        If i > flag Then
            If tb.Cols(i-1).GrandTotal Then
                hui.Cols(i).Style = sender.Cols(i).Style    '同步列样式
                hui(1,i) = sender.Aggregate(C1.Win.C1FlexGrid.AggregateEnum.Sum,0,i,sender.Rows.count-2,i,1)
            Else
                hui(1,i) = Nothing
            End If
           
        End If
    Next
    hui.Cols.Frozen = sender.Cols.Frozen   '同步冻结列
    hui.ScrollPosition = sender.ScrollPosition   '同步水平滚动
   
    hui.ExtendLastCol = sender.ExtendLastCol
    'End If
Else   '检查并删除控件
    If sender.Controls.ContainsKey("Myhuizong")  Then  '删除控件
        sender.Controls.RemoveByKey("Myhuizong")
    End If
End If

 回到顶部