7,765
社区成员
发帖
与我相关
我的任务
分享
Dim h As Integer
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 Sub
Private Sub MSHFlexGrid1_Scroll()
With MSHFlexGrid1
.RowPosition(h) = .TopRow + 3
h = .TopRow + 3
End With
End Sub
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 Sub
Private Sub MSHFlexGrid1_Scroll()
With MSHFlexGrid1
.RowPosition(h) = .TopRow + 3
h = .TopRow + 3
End With
End Sub