了解Eblib的高手请进! (50分)

清嘴

Unregistered / Unconfirmed
GUEST, unregistred user!
针对DBGridEh
怎样对没有挂数据库字段的列进行赋值操作?
即(FieldName='')
 
好像不可以
 
高手啊!
 
用计算字段?
 
我试过,没成功!!
你可以参考DBGRIDEH中的CURRENCY.~pas文件和DBSUMLIST.PAS看看,我是用DBSUMLIST.PAS 中的方法
自己建一个。
想该DBSUMLIST.PAS,让它能在SUMCOLLECTION的DBSUM的FIELDNAME中加入DBGRIDEH .FIELDS[1]*DBGRIDEH .FIELDS[2]
没有成功,你试试吧,好了教我。
 
不是计算字段用的
 
1、新建工程;
2、在Form1中放Table1,datasource1,dbgrid1;
3、设置数据库联接Table1.databasename='DBDEMOS',
tablename='custoly.db'
3、在dbgrid中加3个column,前面两个连数据,在OnDrawColumnCell事件写程序。

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,

Forms,
Dialogs, DB, DBTables, Grids, DBGrids;

type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
Table1: TTable;
DataSource1: TDataSource;
procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if Column.FieldName='' then
begin
DBGrid1.Canvas.TextOut(rect.Left,rect.Top,'测试');
end;
end;

end.

行了
 
接受答案了.
 

Similar threads

S
回复
0
查看
958
SUNSTONE的Delphi笔记
S
S
回复
0
查看
779
SUNSTONE的Delphi笔记
S
S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
970
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
顶部