Don't say the SQL statement is used to implement paging, I didn't ID field in the table, don't know whether to use ADOQuery properties for demand in this picture, if you can, beg god give detailed steps! http://ymg97526.blog.163.com/blog/static/1736581602011332353527/this link is others use DELPHI implementation, but I was using a c + + BUILDER, who can give the code in the c + + BUILDER!
CodePudding user response:
Var Page: Integer=1;
//custom things
Procedure TForm1. ShowRecordSetData;
Var I, j: Integer;
Item: TListItem;
The begin
If Page<1 then Page:=1;
If Page> ADOQuery1. You. PageCount then Page:=ADOQuery1. You. PageCount;//PageCount: total number of page
ADOQuery1. You. AbsolutePage:=Page;//AbsolutePage: specify the current page
Edit1. Text:=IntToStr (Page);
ListView1. Items. The Clear;
For I:=1 to ADOQuery1. You. PageSize do
The begin
Item:=Listview1. Items. The Add;
Item. Caption:=IntToStr (ADOQuery1. You. AbsolutePosition);//AbsolutePosition: record pointer position
Item. ImageIndex:=1;
For j:=0 to ADOQuery1. Do FieldCount - 1
The begin
If ADOQuery1. Fields [j]. Journal of DataType=ftFloat then
Item. SubItems. Add (SysUtils. FormatFloat (' # # # #, # # #. 00 ', ADOQuery1. You. The Fields [j]. Value))
The else
Item. SubItems. Add (ADOQuery1. You. Fields [j]. Value);
end;
ADOQuery1. You. MoveNext;
If ADOQuery1. You. EOF then Exit;
end;
//Edit1. Text:=IntToStr (Page); . This sentence to buy before, so when you exit if EOF is true, that can't to assignment Exit1
end;
Procedure TForm1. Button1Click (Sender: TObject);
The begin
Page:=1;
ShowRecordSetData;
end;
Procedure TForm1. Button2Click (Sender: TObject);
The begin
System. Dec (Page);//Page:=Page - 1;
ShowRecordSetData;
end;
Procedure TForm1. Button3Click (Sender: TObject);
The begin
System. The Inc (Page);
ShowRecordSetData;
end;
Procedure TForm1. Button4Click (Sender: TObject);
The begin
Page:=ADOQuery1. You. PageCount;
ShowRecordSetData;
end;
Procedure TForm1. Button5Click (Sender: TObject);
The begin
Page:=SysUtils. StrToIntDef (Edit1. Text, 0).
ShowRecordSetData;
end;
Procedure TForm1. FormCreate (Sender: TObject);
Var Col: TListColumn;
I: Integer;
The begin
ADOQuery1. The ConnectionString:='. The Provider=Microsoft Jet. The OLEDB. 4.0; + '
'Data Source=e: \ McMygs MDB. + '
'Persist Security Info=False; + '
'the Jet OLEDB: Database Password=';
ADOQuery1. Close;
ADOQuery1. SQL. Text:='Select FPHM, bhsje, se, JSHJ from zyfp';
ADOQuery1. Open;
//ADOQuery1. You: page positioning function; Data sets can be paged processing
ADOQuery1. You. PageSize:=12;//each page shows the number of records; Needs to be in on the data set to
Label2. Caption:=Format (' % d pages in total, [ADOQuery1. You. PageCount]);
//TViewStyle=(vsIcon vsSmallIcon, vsList, vsReport);
ListView1. ViewStyle:=vsReport;
Col:=Listview1 Columns. The Add;
Col. Caption:='No.';
For I:=0 to System. Mr Pred (ADOQuery1. Fields. Count) do
The begin
Col:=Listview1 Columns. The Add;
Col. Caption:=ADOQuery1. Fields [I] FieldName.
Col. Alignment:=taRightJustify;
Col. AutoSize:=True;
end;
Listview1. RowSelect:=True;//select the entire line
Listview1. GridLines:=True;//show the line
Listview1. SmallImages:=ImageList1;
end;
A translation first,
the author
//var Page: Integer=1;
Int Page=1;
//custom things
//procedure TForm1. ShowRecordSetData;
Void TForm1: : ShowRecordSetData ()
{
//var I, j: Integer;
int i,j;
//Item: TListItem;
TListItem * Item;
//Item=new TListItem ();
//the begin
//if Page<1 then Page:=1;
If (Page<1) Page=1;
//if Page> ADOQuery1. You. PageCount then
If (Page> ADOQuery1 - & gt; You - & gt; PageCount)
//Page:=ADOQuery1. You. PageCount;//PageCount: total number of page
Page=ADOQuery1 - & gt; You - & gt; PageCount;
//ADOQuery1. You. AbsolutePage:=Page;//AbsolutePage: specify the current page
ADOQuery1 - & gt; You - & gt; AbsolutePage=Page;
//Edit1. Text:=IntToStr (Page);
Edit1 - & gt; Text=IntToStr (Page);
//ListView1. Items. The Clear;
ListView1 - & gt; The Items - & gt; The Clear ();
//for I=1 to ADOQuery1. You. PageSize do
for(i=1; i<=ADOQuery1. You. PageSize; I++)
//the begin
{
//Item:=Listview1. Items. The Add;
The Item=Listview1 - & gt; The Items - & gt; The Add ();
//Item. Caption:=IntToStr (ADOQuery1. You. AbsolutePosition);//AbsolutePosition: record pointer position
Item - & gt; Caption=IntToStr (ADOQuery1 - & gt; You - & gt; AbsolutePosition);
Item - & gt; ImageIndex=1;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull