我用vsflexgrid显示数据库中的记录
我用Select * from 零件信息
明明有2446条记录,但是vsflexgrid只能显示100条记录
vsflexgrid旁边的滚动栏显示的确是有这么多记录]
可是只有前100条记录正常显示,后面的全都是空行!
我用Select * from 零件信息
明明有2446条记录,但是vsflexgrid只能显示100条记录
vsflexgrid旁边的滚动栏显示的确是有这么多记录]
可是只有前100条记录正常显示,后面的全都是空行!
Public Sub FillRecorSetToFlex(oFlex As MSFlexGrid, recTmp As Recordset)
Dim fieTmp As Field
Dim sTmp As String
Dim sCaption As String
Dim lI As Long
On Error Resume Next
'If recTmp.EOF And recTmp.BOF Then
' oFlex.Rows = 2
' Exit Sub '如果记录集中不含任何记录,则什么都不干
'End If
oFlex.Clear
oFlex.Cols = recTmp.Fields.Count - 1 For Each fieTmp In recTmp.Fields
DoEvents
sCaption = sCaption & "|^" & fieTmp.Name
Next fieTmp 'sCaption = sCaption & "|"
oFlex.FormatString = sCaption
SetCellWidth oFlex
oFlex.ColWidth(0) = 300
If recTmp.EOF And recTmp.BOF Then oFlex.Rows = 2
Exit Sub '如果记录集中不含任何记录,则什么都不干
End If
'填充标题栏
recTmp.MoveFirst
recTmp.MoveLast '填充栏中数据
oFlex.Cols = recTmp.Fields.Count + 1 '设置列数
oFlex.Rows = 2 '设置行数
recTmp.MoveFirst
For lI = 0 To recTmp.RecordCount - 1
For Each fieTmp In recTmp.Fields '取得一个记录的全部字段的值
sTmp = sTmp & vbTab & fieTmp.Value
DoEvents
Next fieTmp
recTmp.MoveNext
oFlex.AddItem sTmp '添加数据
sTmp = "" '清空变量
Next lI
End Sub