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 '如果处于合计模式
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 '不能使用控件
'.styles.emptyarea.backcolor = sender.styles.emptyarea.backcolor
.FocusRect = C1.Win.C1FlexGrid.FocusRectEnum.None '不显示焦点框
.HighLight = C1.Win.C1FlexGrid.HighLightEnum.Never '不高亮显示选定区
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 = 21 'hg + 2
.Rows(1).Height = 21 ' hg
End With
Dim sLightBlue As C1.Win.C1FlexGrid.CellStyle = hui.Styles.Add("LightBlue")
sLightBlue.BackColor = Color.PaleGreen
sLightBlue.ForeColor = Color.red
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 '同步列样式
'hui.BackColor = Color.Blue
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
'hui.rows(1)(sender.cols("客户ID").Index) = "我想怎么显示就怎么显示"
hui.rows(1)(sender.cols("余额").Index) = hui.Rows(1)(sender.cols("收入").Index) - hui.Rows(1)(sender.cols("支出").Index)
sender.Cols(0).width = 30
hui.Cols(0).width = 30
'End If
Else '检查并删除控件
If sender.Controls.ContainsKey("Myhuizong") Then '删除控件
sender.Controls.RemoveByKey("Myhuizong")
End If
End If