ListView与MSFLEXGRID
对ListView,我们可以对它里面的数据进行某列汇总,代码如下:With ListView1.ListItems.Add
.SubItems(5) = " 本 月 合 计"
.SubItems(6) = IIf(IsNull(JFHJ), "", Format(JFHJ, "#,##0.00"))
.SubItems(7) = IIf(IsNull(DFHJ), "", Format(DFHJ, "#,##0.00"))
End With
ListView1.ListItems(ListView1.ListItems.Count).ListSubItems(5).ForeColor = vbRed
With ListView1.ListItems.Add
.SubItems(5) = " 本 年 累 计"
.SubItems(6) = IIf(IsNull(JFHJ_LJ), "", Format(JFHJ_LJ, "#,##0.00"))
.SubItems(7) = IIf(IsNull(DFHJ_LJ), "", Format(DFHJ_LJ, "#,##0.00"))
End With
对MSFLEXGRID这个控件可以这样吗?代码如何写?
Option Explicit设置好行数,给单元格赋值就行了.
Private Sub Form_Load()
Dim i As Integer
With MSHFlexGrid1
.Rows = 10
.Cols = 5
For i = 1 To 9
.TextMatrix(i, 0) = CStr(i)
.TextMatrix(i, 1) = CStr(Round(Rnd * 100, 2))
.TextMatrix(i, 2) = CStr(Round(Rnd * 100, 2))
.TextMatrix(i, 3) = CStr(Round(Rnd * 100, 2))
.TextMatrix(i, 4) = CStr(Round(Rnd * 100, 2))
'添加小计单元格
Next i
'添加1行并显示小计数
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = "小计"
.TextMatrix(i, 1) = CStr("第1列小计")
.TextMatrix(i, 2) = CStr("第2列小计")
.TextMatrix(i, 3) = CStr("第3列小计")
.TextMatrix(i, 4) = CStr("第4列小计")
End With
End Sub
给个示例好吗? http://topic.csdn.net/u/20100621/15/02a34bdf-88bd-41c6-9305-953d0115e6b8.html看InputMSFG部分
补充:VB , 控件