我在使用DBGrid时,如何在DBGrid中显示数据记录行号????多谢了!!! 我在使用DBGrid时,由于从数据库中取得的数据中没有行号,但是想在DBGrid中将每一条数据记录的行号同时作为一列显示在 DBGrid中。不知道如何显示的,如何来实现????请高手帮忙!!多谢了!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //转载,来自于某某大侠(忘了)unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DBGrids, Grids, DB, ADODB;const ROWCNT = 20;type tmygrid = class(tdbgrid) protected procedure Paint; override; procedure DrawCell(ACol: Integer; ARow: Integer; ARect: TRect; AState: TGridDrawState); override; public constructor create(AOwner: TComponent); override; destructor destroy; override; end;type TForm1 = class(TForm) Button2: TButton; DataSource1: TDataSource; ADOTable1: TADOTable; procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1; mygrid: tmygrid;implementation{$R *.dfm}constructor tmygrid.create(AOwner: TComponent);begin inherited create(Owner); RowCount := ROWCNT;end;destructor tmygrid.destroy;begin inherited;end;procedure tmygrid.Paint;begin RowCount := ROWCNT; if dgIndicator in options then ColWidths[0] := 30; inherited;end;procedure tmygrid.DrawCell(ACol: Integer; ARow: Integer; ARect: TRect; AState: TGridDrawState);begin inherited; if (ARow >= 1) and (ACol = 0) then Canvas.TextRect(ARect, ARect.Left, ARect.Top, IntToStr(ARow));end;procedure TForm1.Button2Click(Sender: TObject);begin mygrid := tmygrid.create(Self); mygrid.parent := self; mygrid.left := 0; mygrid.top := 0; mygrid.Height := 400; mygrid.DataSource := DataSource1end;end. String引用计数 关于 积分的实现 HTTP 问题?请问如何做与网页的接口?急!!! 以分求知识~~虽然分不多请多多帮忙 Ftp 错误代码 550,如何解决呢 见过这样的问题没??'Application is not licensed to this feature' 大哥们啦,又拉兄弟一把吧!我又遇到二个难点了 哪里有Kylix2.0的光盘镜像文件(ISO)可以下载? 怎样让上下键控制焦点的移动! Windows下怎么通过代码判断一个进程真的彻底没响应了? 小弟刚学Delphi,小小问题问一问! 怎么样定制这样的菜单
unit Unit1;interfaceuses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
StdCtrls,
DBGrids,
Grids,
DB, ADODB;const
ROWCNT = 20;type
tmygrid = class(tdbgrid)
protected
procedure Paint; override;
procedure DrawCell(ACol: Integer; ARow: Integer; ARect: TRect; AState: TGridDrawState); override;
public
constructor create(AOwner: TComponent); override;
destructor destroy; override;
end;
type
TForm1 = class(TForm)
Button2: TButton;
DataSource1: TDataSource;
ADOTable1: TADOTable;
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
mygrid: tmygrid;implementation{$R *.dfm}constructor tmygrid.create(AOwner: TComponent);
begin
inherited create(Owner);
RowCount := ROWCNT;
end;destructor tmygrid.destroy;
begin
inherited;
end;procedure tmygrid.Paint;
begin
RowCount := ROWCNT;
if dgIndicator in options then
ColWidths[0] := 30;
inherited;
end;procedure tmygrid.DrawCell(ACol: Integer; ARow: Integer; ARect: TRect; AState: TGridDrawState);
begin
inherited;
if (ARow >= 1) and (ACol = 0) then
Canvas.TextRect(ARect, ARect.Left, ARect.Top, IntToStr(ARow));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
mygrid := tmygrid.create(Self);
mygrid.parent := self;
mygrid.left := 0;
mygrid.top := 0;
mygrid.Height := 400;
mygrid.DataSource := DataSource1
end;end.