- 1、本文档共28页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
ADO
ADO 对查询出的数据分页显示delphi(转)
unit
unit MainFrm;
interface
interface
uses
uses
Classes, Controls, Forms, Grids, ToolWin, ComCtrls, StdCtrls, ExtCtrls, DB,
Classes, Controls, Forms, Grids, ToolWin, ComCtrls, StdCtrls, ExtCtrls, DB,
ADODB;
ADODB;
type
type
TfrmMain = class(TForm)
TfrmMain = class(TForm)
cnn:
cnn: TADOConnection;
rst:
rst: TADODataSet;
pnlNavigate:
pnlNavigate: TPanel;
btnFirst: TButton;
btnFirst: TButton;
btnPrior: TButton;
btnPrior: TButton;
btnNext: TButton;
btnNext: TButton;
btnLast:
btnLast: TButton;
edtPageNO: TEdit;
edtPageNO: TEdit;
sgData:
sgData: TStringGrid;
procedure
procedure FormCreate(Sender: TObject);
procedure btnFirstClick(Sender:
procedure btnFirstClick(Sender: TObject);
procedure edtPageNOKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure edtPageNOKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
private
private
FPageNo: Integer;
FPageNo: Integer;
procedure SetPageNo(Value: Integer);
procedure SetPageNo(Value: Integer);
public
public
property
property PageNo: Integer read FPageNo write SetPageNo;
end;
end;
var
var
frmMain: TfrmMain;
frmMain: TfrmMain;
implementation
implementation
uses
uses
Windows, SysUtils;
Windows, SysUtils;
{$R
{$R *.dfm}
const
const
PAGE_SIZE =
PAGE_SIZE = 6;
procedure TfrmMain.FormCreate(Sender:
procedure TfrmMain.FormCreate(Sender: TObject);
i: Integer;
i: Integer;
var
begin
begin
SetWindowLong(edtPageNO.Handle,GWL_STYLE,GetWindowLong(edtPageNo.Handle,
SetWindowLong(edtPageNO.Handle,GWL_STYLE,GetWindowLong(edtPageNo.Handle,
GWL_STYLE) or ES_CENTER or
GWL_STYLE) or ES_CENTER or ES_NUMBER);
rst.Active :=
rst.Active := True;
rst.Recordset.PageSize :=
rst.Recordset.PageSize := PAGE_SIZE;
sgData.ColCount := rst.FieldCount + 1;
sgData.ColCount := rst.FieldCount + 1;
for
for i := 0 to rst.FieldCount - 1 do
begin
begin
sgData.ColWidths[i
sgData.ColWidths[i + 1] := rst.Fields[i].DisplayWidth * Canvas.TextWidth(0);
sgData.Cells[i
sgData.Cells[i + 1, 0] := rst.Fields[i].DisplayName;
end;
文档评论(0)