Oh, not .Net.
These days have answered questions on the forum, and some people put this pagination of this DataGrid control.
Please see:
Database: TEST2000.MDB
Table: Numbers
Field: ID (Auto Number), Anumber (Digital)
Because the DataGrid control we use a direct binding recordset to display data. So the paging process We use an indirect approach to define another recordset OBJRS, pay the paginum to ObJRS. Then bound DataGrid
'The effect is not bad, I added a detailed note? Like PageSize, the usage of AbsolutePage can be referred to MSDN
New Construction Project in VB, Add DataGrid Control, Button CmdpRevious and CmdNext, Text Box TxtPage
'Reference Microsoft Active Data Object 2.x Object Library
Option expedition
DIM Conn as adodb.connection
DIM LCURRENTPAGE AS Long
Private subduDNext_click ()
LcurrentPage = lcurrentpage 1
Call loadControl (lcurrentpage)
End Sub
Private subdprevious_click ()
IF lcurrentpage> 1 THEN
LcurrentPage = lcurrentpage - 1
Call loadControl (lcurrentpage)
END IF
End Sub
Private sub flow_load ()
SET CONN = New Adodb.Connection
Conn.cursorLocation = aduseclient
Conn.open "provider = microsoft.jet.oledb.4.0; data source =" & app.path & "/test2000.mdb;"
LcurrentPage = 1
Call loadControl (lcurrentpage)
End Sub
Private Sub LoadControl (LPAGE As Long)
Dim Adoprimaryrs as adodb.recordset
DIM LPAGECUNT As Long
DIM NPAGESIZE AS INTEGER
DIM LCOUNT AS Long
'Record of each page
Npagesize = 10
Set adoprimaryrs = new adoDb.recordset
AdopriMaryrs.open "Select * from Numbers", Conn, AdopenStatic, AdlockOptimistic
Adoprimaryrs.pageSize = npagesize
'
LPageCount = adoprimaryrs.pagecount
IF lcurrentpage> LPAGECUNT THEN
LcurrentPage = LPAGECOUNT
END IF
AdopriMaryrs.absolution = lcurrentpage
'Define another record set
Dim objrs as new adoDb.recordset
'Add a field name
For LCOUNT = 0 to Adoprimaryrs.fields.count - 1
Objrs.fields.Append Adoprimaryrs.fields (LCOUNT) .Name, Advarchar, Adoprimaryrs.fields (LCOUNT) .definedsiziext
'Open record set
Objrs.open
'Add the specified record number loop to OBJRS
For LCOUNT = 1 to NPAGESIZE
Objrs.addnew
Objrs! id = adoprimaryrs! ID
Objrs! Anumber = adoprimaryrs! Anumber
Adoprimaryrs.movenext
NEXT
'Binding
SET DATAGRID1.DATASOSOURCE = ObJRS
'Display pages in text box
TXTPAGE = LPAGE & "/" & adoprimaryrs.pagecount
End Sub
Private Sub Form_Unload (Cancel AS Integer)
IF not conn is nothing then
Conn.close
END IF
Set conn = Nothing
End Sub
The number of pages in the text box, enter the carriage return to the specified location
Private sub txtpage_keydown (Keycode As Integer)
LcurrentPage = VAL (txtpage.text)
Call loadControl (lcurrentpage)
End Sub