1,451
社区成员
发帖
与我相关
我的任务
分享
If not Rs.eof or Rs.bof then 'RS为从数据库返回的记录集
Do While Not (Rs.eof or Rs.bof)
With MFG
nr = MFG.Rows - 1
'产品信息
.TextMatrix(nr, 1) = rs!ID
.TextMatrix(nr, 2) = rs!kID
.TextMatrix(nr, 3) = rs!cID
.TextMatrix(nr, 4) = rs!uID
.TextMatrix(nr, 5) = rs!uClass
.Rows = .Rows + 1
.TopRow = .Rows - 1
List1.AddItem Trim(Rs!ID) '加上此行,在LIST1控件里能正常显示出此字段的信息,但是MSFLEXGRID不显示
DoEvents
End With
Doevents
Loop
End If
'方法1,逐行赋值:
with hflexgrid1
.rows=rs.recordcount+1
for i_row=1 to rs.recordcount
.textmatrix(i_row,0)=rs!字段1 & ""
.textmatrix(i_row,1)=rs!字段2 & ""
.textmatrix(i_row,2)=rs!字段3 & ""
rs.movenext
next i_row
end with
rs.close
'方法2,记录集绑定mshflexgrid控件:
rs.open " select * from 表名",conn,adopenkeyset,adlockreadonly
set mshflexgrid1.datasource=rs
rs.close
Do While Not (Rs.eof or Rs.bof)
With MFG
nr = MFG.Rows - 1
'产品信息
.TextMatrix(nr, 1) = rs!ID
.TextMatrix(nr, 2) = rs!kID
.TextMatrix(nr, 3) = rs!cID
.TextMatrix(nr, 4) = rs!uID
.TextMatrix(nr, 5) = rs!uClass
.Rows = .Rows + 1
.TopRow = .Rows - 1
List1.AddItem Trim(Rs!ID) '加上此行,在LIST1控件里能正常显示出此字段的信息,但是MSFLEXGRID不显示
rs.movenext '--这个不加上,你是怎么跳出循环的?
DoEvents
End With
Doevents
Loop