Dim sender As object = Args(0)
Dim e 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
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 '同步水平滚动
hui(1,1) = "我的合计"
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
Dim t As Table = Tables("收保_退保对应查询表")
Dim pdr As DataRow = Nothing
Dim sum As Double = 0
For Each dr As DataRow In t.DataTable.Select("", "piao据号码, 支piao日期")
If pdr Is Nothing OrElse pdr("piao据号码")<>dr("piao据号码") Then
sum += dr("piao面金额")
End If
pdr = dr
Next
hui.rows(1)(sender.cols("piao面金额").Index) = sum
hui.rows(1)(sender.cols("余额").Index) = hui.Rows(1)(sender.cols("piao面金额").Index) - hui.Rows(1)(sender.cols("开具支piao明细金额").Index)
'End If
Else '检查并删除控件
If sender.Controls.ContainsKey("Myhuizong") Then '删除控件
sender.Controls.RemoveByKey("Myhuizong")
End If
End If