用 MSHFlexGrid . 先确定 数据所需的 行和列数. 在用 .TextArray 填加数据 With MSHFlexGrid .Rows = xxx .Cols = xxx '//从 数据集 读如数据并填充 Do Until Rs.Eof For I =0 To (.Rows-1) For J=0 To (.Cols -1) .TextArray(faIndex(I,J)) = Rs.Fields("Data").Value Next Next Loop End with关于 faIndex 函数, MSDN 上已有.
先确定 数据所需的 行和列数.
在用 .TextArray 填加数据
With MSHFlexGrid
.Rows = xxx
.Cols = xxx
'//从 数据集 读如数据并填充
Do Until Rs.Eof
For I =0 To (.Rows-1)
For J=0 To (.Cols -1)
.TextArray(faIndex(I,J)) = Rs.Fields("Data").Value
Next
Next
Loop
End with关于 faIndex 函数, MSDN 上已有.
-------------------------------------------------------------------
下面的代码给你参考一下:
m1 是个 Grid 控件。Function Getpagedate(ByVal TSQL As String, ByVal pagenumber As Integer, ByVal size As Integer) As Long
Screen.MousePointer = 11
Dim x As IntegerIf rs1.State = 1 Then rs1.Close
rs1.CursorLocation = adUseClient
rs1.Open TSQL, conn1, adOpenForwardOnly, adLockReadOnly
If rs1.EOF Then
mg1.Rows = 1
mg1.Rows = mg1.Rows + 1
mg1.FixedRows = 1
Label2(4).Caption = "Record Count:" & "0" & " Page Count:" & "0"
Screen.MousePointer = 0
Exit Function
End Ifmg1.Rows = 1
mg1.Cols = rs1.Fields.Count
rs1.PageSize = size
If pagenumber > rs1.PageCount Then
txtpn = 0
pagenumber = 1
ElseIf pagenumber <= 0 Then
txtpn = rs1.PageCount + 1
pagenumber = rs1.PageCount
End If
rs1.AbsolutePage = pagenumber
txtpn.Text = rs1.AbsolutePage
mg1.Visible = False
With mg1
Do While Not rs1.EOF And rs1.AbsolutePage = pagenumber
.Rows = .Rows + 1
.FixedRows = 1
For x = 0 To rs1.Fields.Count - 1
.TextMatrix(.Rows - 1, x) = IIf(IsNull(rs1.Fields(x).value), "", rs1.Fields(x).value)
If x = 4 Or x = 3 Then
.TextMatrix(.Rows - 1, x) = Format(.TextMatrix(.Rows - 1, x), "Fixed")
If Val(.TextMatrix(.Rows - 1, x)) = 0 Then .TextMatrix(.Rows - 1, x) = ""
.ROW = .Rows - 1: .COL = x
If Val(.TextMatrix(.Rows - 1, x)) < 0 Then .CellForeColor = vbRed Else .CellForeColor = vbBlue
End If
Next
rs1.MoveNext
Loop
Label2(4).Caption = "Record Count:" & CStr(rs1.RecordCount) & " Page Count:" & rs1.PageCount
Getpagedate = rs1.RecordCount
rs1.Close
Screen.MousePointer = 0
mg1.Visible = True
.Refresh
End With
End Function