dim nPageNo as long dim i as long rs.PageSize = 100 If rs.PageCount < nPageNo Or nPageNo <= 0 Then nPageNo = 1 End If
If rs.RecordCount > 0 Then rs.AbsolutePage = nPageNo End If
Do Until rs.EOF If i >= rs.PageSize Then Exit Do rs.movenext loop
我改动的代码可是还不行。 intPage = 1 Re.PageSize = 100 Re.AbsolutePage = intPage For intRecord = 1 To Re.PageSize Set DataGrid1.DataSource = Re Re.MoveNext count = count + 1 If count = Re.PageSize Then Exit For If Re.EOF Then Exit For End If
用Sql语句就可以了: '只显示前面一百条 Dim Con As ADODB.Connection Dim Rs As ADODB.RecordsetSet Con = New ADODB.Connection Set Rs = New ADODB.Recordset Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=D:\Microsoft Visual Studio\VB98\BIBLIO.MDB" Con.Open Con.ConnectionString Rs.Open "select Top 100 * from Publishers", Con, 1, 3 Set DataGrid1.DataSource = Rs
dim i as long
rs.PageSize = 100
If rs.PageCount < nPageNo Or nPageNo <= 0 Then
nPageNo = 1
End If
If rs.RecordCount > 0 Then
rs.AbsolutePage = nPageNo
End If
Do Until rs.EOF
If i >= rs.PageSize Then Exit Do
rs.movenext
loop
intPage = 1
Re.PageSize = 100
Re.AbsolutePage = intPage
For intRecord = 1 To Re.PageSize
Set DataGrid1.DataSource = Re
Re.MoveNext
count = count + 1
If count = Re.PageSize Then Exit For
If Re.EOF Then
Exit For
End If
Next intRecord
End If
自己用代码控制。
所以我建议你自己作一个控件,datagrid+一个button
.---------------------------------------------------------
Montaque==Digitalboy==Houyongfeng==Monkey
当时有两种方法,
一种是用两个MSFlexGrid控件,一个用来装所有数据
一个用来显示,
一种是只用一个控件,装所有数据,向它发送消息,如同点击了Scroll一样
SendMessage MFGridPrv.hWnd, WM_VSCROLL, SB_LINEDOWN, 1
我用后一种方法,加上计算应该滚动多少次的判断代码实现UP~~
'只显示前面一百条
Dim Con As ADODB.Connection
Dim Rs As ADODB.RecordsetSet Con = New ADODB.Connection
Set Rs = New ADODB.Recordset
Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=D:\Microsoft Visual Studio\VB98\BIBLIO.MDB"
Con.Open Con.ConnectionString
Rs.Open "select Top 100 * from Publishers", Con, 1, 3
Set DataGrid1.DataSource = Rs