关于VSFlexgird的最后一行合计问题请教
Private Sub Form_Load()Me.Icon = MDIMain.Icon
Call InforVfgKucInfo
End Sub
Public Sub InforVfgKucInfo()
Dim Rs As New ADODB.Recordset
Dim Sql As String
Sql = "select cm1,cm2,cm3,cm4,cm5,cm6 from fkuc where gch='" & TexGch.Text & "'"
Rs.Open Sql, Conn, 1, 1
If Not Rs.EOF Then
If InStr(1, Tex易做图.Text, "男") Then
With VfgKcInfo
Set .DataSource = Rs
'全局内容居中
.ColAlignment(-1) = flexAlignCenterCenter
'设置自动换行
.WordWrap = True
.AutoSizeMode = flexAutoSizeRowHeight
.AutoSize 0, .Cols - 1, 1
'全行选择
.SelectionMode = 1
'列头设置
.TextMatrix(0, 0) = "颜色"
.ColWidth(0) = 450
If Text1.Text <> "" Then
.Rows = UBound(Split(Text1.Text, ",")) + 2
For i = LBound(Split(Text1.Text, ",")) To UBound(Split(Text1.Text, ","))
b = Split(Text1.Text, ",")
.TextMatrix(i + 1, 0) = b(i)
.RowHeight(i + 1) = 337
Next
End If
.TextMatrix(0, 1) = "39"
.ColWidth(1) = 952
.TextMatrix(0, 2) = "40"
.ColWidth(2) = 952
.TextMatrix(0, 3) = "41"
.ColWidth(3) = 952
.TextMatrix(0, 4) = "42"
.ColWidth(4) = 952
.TextMatrix(0, 5) = "43"
.ColWidth(5) = 952
.TextMatrix(0, 6) = "44"
.ColWidth(6) = 952
End With
End if
Rs.Close
Set Rs=Nothing
End Sub
Private Sub VfgKcInfo_AfterSort(ByVal Col As Long, Order As Integer) '排序后添加合计项
With VfgKcInfo
If .TextMatrix(.Rows - 1, 1) <> "合 计" Then '判断如果最后列不是合计行那么添加合计行
.Rows = .Rows + 1
Dim r&, c&, tot!
For c = 6 To 8
tot = 0
For r = 1 To .Rows - 2
tot = tot + .ValueMatrix(r, c)
Next
.TextMatrix(r, c) = tot
Next
.TextMatrix(.Rows - 1, 1) = "合 计"
.Cell(flexcpAlignment, .Rows - 1, 1, .Rows - 1, 1) = flexAlignCenterCenter '合计两字居中对齐
End If
.Redraw = True
End With
End Sub
Private Sub VfgKcInfo_BeforeSort(ByVal Col As Long, Order As Integer) '排序前删除合计项
With VfgKcInfo
If .TextMatrix(.Rows - 1, 1) = "合 计" Then '判断最后列是否是合计行
.Redraw = False
.RemoveItem (.Rows - 1)
End If
End With
End Sub
代码貌似都没写错呀,怎么就是没有"最后一行的合计效果呢?" vsf有自己的合计的subtotal。
从你的代码中,看不到你的需求是什么。
.TextMatrix(r+1, c) = tot
依然没效果呀..
我知道这个,但是这个具体的应用还是不明白.能否提供一个示例源码给我.. 没高手了吗? subtotal的例子很多,帮助文件里有,你的要求不讲一下? 楼主确定调试过吗
InforVfgKucInfo方法里缺少end if
不知道你怎么调试的?
补充:VB , 控件