Dim i As Integer, j As Integer, he As String, r As Integer, N As Integer .FixedCols = 1: .FixedRows = 1 he = "|^xxx1|^xxx2|^xxx3|^xxx4|^xxx5|^xxx6|^xxx7|^xxx8" .FormatString = he .RowHeight(-1) = 400: .ColWidth(-1) = 800: .ColWidth(0) = 200 .Height = .RowHeight(1) * 5 + 290 + 20 .Width = .ColWidth(1) * (.Cols - 2) + 490
For i = 1 To .Rows - 2 For j = 1 To .Cols - 1 If j = 1 Then .TextMatrix(i, j) = "name" & i Else .TextMatrix(i, j) = i + j End If Next Next .Row = i: .Col = 1: .Text = "合计" For j = 1 To .Cols - 1 If j > 1 Then For r = 1 To .Rows - 2 N = N + .TextMatrix(r, j) Next .TextMatrix(r, j) = N End If .Col = j: .CellAlignment = 4 .CellBackColor = &H80FFFF: Next .RowPosition(i) = (.Height - 290) \ .RowHeight(1) - 1 h = (.Height - 290) \ .RowHeight(1) - 1 End With
End SubPrivate Sub MSHFlexGrid1_Scroll() With MSHFlexGrid1 .RowPosition(h) = .TopRow + 3 h = .TopRow + 3 End WithEnd Sub
为你做了个mshflexgrid的最底一行固定行的例子,复制了去测试一下,可以举一反三的再增加功能。Dim h As IntegerPrivate Sub Form_Load()
Dim i As Integer, j As Integer, he As String, r As Integer, N As Integer .FixedCols = 1: .FixedRows = 1 he = "|^xxx1|^xxx2|^xxx3|^xxx4|^xxx5|^xxx6|^xxx7|^xxx8" .FormatString = he .RowHeight(-1) = 400: .ColWidth(-1) = 800: .ColWidth(0) = 200 .Height = .RowHeight(1) * 5 + 290 + 20 .Width = .ColWidth(1) * (.Cols - 2) + 490
For i = 1 To .Rows - 2 For j = 1 To .Cols - 1 If j = 1 Then .TextMatrix(i, j) = "name" & i Else .TextMatrix(i, j) = i + j End If Next Next .Row = i: .Col = 1: .Text = "合计" For j = 1 To .Cols - 1 If j > 1 Then For r = 1 To .Rows - 2 N = N + .TextMatrix(r, j) Next .TextMatrix(r, j) = N End If .Col = j: .CellAlignment = 4 .CellBackColor = &H80FFFF: Next .RowPosition(i) = (.Height - 290) \ .RowHeight(1) - 1 h = (.Height - 290) \ .RowHeight(1) - 1 End With
End SubPrivate Sub MSHFlexGrid1_Scroll() With MSHFlexGrid1 .RowPosition(h) = .TopRow + 3 h = .TopRow + 3 End WithEnd Sub
这个问题很简单,第二个MSHFlexGrid对应的列宽可以指定,也可以指定表结构同第一个MSHFlexGrid的,只不过记录为空而已.如下边所示,表中的id不可能>90000000,实现结构一样却没有数据,再并上一条合计数据,合计值可以实现计算好替换了即可 rs.Open "select 字段1,字段2,字段3 from biao where id>90000000 union select '合计',100,300 ", db, adOpenKeyset, adLockOptimistic MSHFlexGrid1.DataSource = rs 就lz的这个问题而言,还可以只用一个MSHFlexGrid控件,sql语句照样union一条合计数据即可
有别的开发的可以,如vsf
另外对你帖图比较感兴趣.http://www.2ylighting.com/About.asp这是灯具厂的网站,你如何传上去的.因为,我发帖子需要有贴图,不好解决,比较头疼.
为你做了个mshflexgrid的最底一行固定行的例子,复制了去测试一下,可以举一反三的再增加功能。Private Sub Form_Load()
With MSHFlexGrid1
.Rows = 14: .Cols = 8
.Move 0, 0
Dim i As Integer, j As Integer, he As String, r As Integer, N As Integer
.FixedCols = 1: .FixedRows = 1
he = "|^xxx1|^xxx2|^xxx3|^xxx4|^xxx5|^xxx6|^xxx7|^xxx8"
.FormatString = he
.RowHeight(-1) = 400: .ColWidth(-1) = 800: .ColWidth(0) = 200
.Height = .RowHeight(1) * 5 + 290 + 20
.Width = .ColWidth(1) * (.Cols - 2) + 490
For i = 1 To .Rows - 2
For j = 1 To .Cols - 1
If j = 1 Then
.TextMatrix(i, j) = "name" & i
Else
.TextMatrix(i, j) = i + j
End If
Next
Next
.Row = i: .Col = 1: .Text = "合计"
For j = 1 To .Cols - 1
If j > 1 Then
For r = 1 To .Rows - 2
N = N + .TextMatrix(r, j)
Next
.TextMatrix(r, j) = N
End If
.Col = j: .CellAlignment = 4
.CellBackColor = &H80FFFF:
Next
.RowPosition(i) = (.Height - 290) \ .RowHeight(1) - 1
h = (.Height - 290) \ .RowHeight(1) - 1
End With
End SubPrivate Sub MSHFlexGrid1_Scroll()
With MSHFlexGrid1
.RowPosition(h) = .TopRow + 3
h = .TopRow + 3
End WithEnd Sub
With MSHFlexGrid1
.Rows = 14: .Cols = 8
.Move 0, 0
Dim i As Integer, j As Integer, he As String, r As Integer, N As Integer
.FixedCols = 1: .FixedRows = 1
he = "|^xxx1|^xxx2|^xxx3|^xxx4|^xxx5|^xxx6|^xxx7|^xxx8"
.FormatString = he
.RowHeight(-1) = 400: .ColWidth(-1) = 800: .ColWidth(0) = 200
.Height = .RowHeight(1) * 5 + 290 + 20
.Width = .ColWidth(1) * (.Cols - 2) + 490
For i = 1 To .Rows - 2
For j = 1 To .Cols - 1
If j = 1 Then
.TextMatrix(i, j) = "name" & i
Else
.TextMatrix(i, j) = i + j
End If
Next
Next
.Row = i: .Col = 1: .Text = "合计"
For j = 1 To .Cols - 1
If j > 1 Then
For r = 1 To .Rows - 2
N = N + .TextMatrix(r, j)
Next
.TextMatrix(r, j) = N
End If
.Col = j: .CellAlignment = 4
.CellBackColor = &H80FFFF:
Next
.RowPosition(i) = (.Height - 290) \ .RowHeight(1) - 1
h = (.Height - 290) \ .RowHeight(1) - 1
End With
End SubPrivate Sub MSHFlexGrid1_Scroll()
With MSHFlexGrid1
.RowPosition(h) = .TopRow + 3
h = .TopRow + 3
End WithEnd Sub
rs.Open "select 字段1,字段2,字段3 from biao where id>90000000 union select '合计',100,300 ", db, adOpenKeyset, adLockOptimistic
MSHFlexGrid1.DataSource = rs
就lz的这个问题而言,还可以只用一个MSHFlexGrid控件,sql语句照样union一条合计数据即可