关于DBGrid中行和列的问题:

zsjzwj 2003-09-04 09:51:37


我想在状态栏中动态显示DBGrid中的当前行和列,请问如何实现?
...全文
71 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
Niuniu2003 2003-09-08
  • 打赏
  • 举报
回复
注意:TGrid = class(TDBGrid);的位置; 同时在uses下引用Grids, DBGrids;
例如:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids;

type
TGrid = class(TDBGrid);
TForm1 = class(TForm)
DBGrid1: TDBGrid;
procedure DBGrid1ColEnter(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.DBGrid1ColEnter(Sender: TObject);
var
I,J: Integer;
begin
I:= TGrid(DBGrid1).Row;
J:= TGrid(DBGrid1).col;

end;

end.
frogshero 2003-09-06
  • 打赏
  • 举报
回复
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type
TGrid = class(TDBGrid); <---ok
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
frogshero 2003-09-06
  • 打赏
  • 举报
回复
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type
TGrid = class(TDBGrid) <---ok
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;

zsjzwj 2003-09-06
  • 打赏
  • 举报
回复
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type
TForm1 = class(TForm)
TGrid = class(TDBGrid)
private
{ Private declarations }
public
{ Public declarations }
end;
frogshero 2003-09-05
  • 打赏
  • 举报
回复
TGrid = class(TDBGrid); 你放哪了?
zsjzwj 2003-09-05
  • 打赏
  • 举报
回复
to Niuniu2003(牛牛) :

不用不行呀!

在 TGrid = class(TDBGrid); 编译通不过呀!
zsjzwj 2003-09-04
  • 打赏
  • 举报
回复
我使用
procedure TForm1.DBGrid1CellClick(Column: TColumn);
var
intCol, intRow: integer; //行号 列号
begin
intRow :=GBGrid1.DataSource.DataSet.Recno;
intcol ;=DBGrid1.Col;
end;

但行有了,却在intcol:=DBGrid1.Col; 出现编译错误! 如何解决?
Niuniu2003 2003-09-04
  • 打赏
  • 举报
回复
type
TGrid = class(TDBGrid);

procedure TForm1.DBGrid1Enter(Sender: TObject);
var
I,J: Integer;
begin
I:= TGrid(DBGrid1).Row;
J:= TGrid(DBGrid1).col;
end;
zhudongpo 2003-09-04
  • 打赏
  • 举报
回复
procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField);
var
i, j: integer; //行号 列号
begin
i := inttostr(table1.RecNo);
j := inttostr(column.index);
end;
IwantFlay 2003-09-04
  • 打赏
  • 举报
回复
procedure TForm1.DBGrid1CellClick(Column: TColumn);
var
intCol, intRow: integer; //行号 列号
begin
intRow :=GBGrid1.DataSource.DataSet.Recno;
intcol ;=DBGrid1.Col;
end;
visli 2003-09-04
  • 打赏
  • 举报
回复
procedure TForm1.DBGrid1CellClick(Column: TColumn);
var
i, j: integer; //行号 列号
begin
i := inttostr(table1.RecNo);
j := inttostr(column.id); //或是index
end;
visli 2003-09-04
  • 打赏
  • 举报
回复
procedure TForm1.DBGrid1CellClick(Column: TColumn);
var
i, j: integer; //行号 列号
begin
i := inttostr(table1.RecNo);
j := inttostr(column.id); //或是index
end;
Niuniu2003 2003-09-04
  • 打赏
  • 举报
回复
你用下面的保你没错,我测试过的。
type
TGrid = class(TDBGrid);

procedure TForm1.DBGrid1Enter(Sender: TObject);
var
I,J: Integer;
begin
I:= TGrid(DBGrid1).Row;
J:= TGrid(DBGrid1).col;
end;

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧