'---设置Grid2的0至n-1列的对齐方式和文本内容
For i = 0 To n - 1
Grid2.FormatString = Grid2.FormatString & " |< " & rs.Fields(i).Name
Next
'-------------------------------------------------------
Grid2.Rows = m + 1 '设置Grid2的总行数
Grid2.Cols = n + 1 '设置Grid2的总列数
'---将查询到的记录添加到Grid2中
For i = 1 To m '------------------------------行循环
For j = 1 To n '=====================列循环
Grid2.TextMatrix(i, j) = rs.Fields(j - 1).Value & ""
If m <= 100 Then
If i Mod 2 = 0 Then
Grid2.Col = j
Grid2.Row = i
Grid2.CellBackColor = &HFEFBDE
End If
End If
Next j '=================================
rs.MoveNext
Next i '------------------------------------
'---------------向Grid2中添加查询到的记录
If strsumdemand <> "" Then
opencn
Grid2.Rows = Grid2.Rows + 1
Grid2.TextMatrix(Grid2.Rows - 1, 1) = "合计"
Set rssum = New ADODB.Recordset
rssum.Open strsumdemand & strcondition, cn, adOpenKeyset, adLockReadOnly
For j = 1 To n
For i = 0 To rssum.Fields.Count - 1
If Grid2.TextMatrix(0, j) = rssum.Fields(i).Name Then
Grid2.TextMatrix(Grid2.Rows - 1, j) = _
& rssum.Fields(i).Value & ""
End If
Next i
Next j
closecn
End If
Grid2.MergeCells = flexMergeRestrictColumns
Grid2.MergeCol(1) = True
|