路过的瞧下 ( 积分: 20 )

  • 主题发起人 主题发起人 fuxin198311
  • 开始时间 开始时间
F

fuxin198311

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure DBGridEhDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumnEh;
State: TGridDrawState);
begin
if (TDBGridEH(Sender).DataSource.DataSet.RecNo Mod 2=0) then
TDBGridEH(Sender).Canvas.Brush.Color:=rgb(255,245,249)
else
TDBGridEH(Sender).Canvas.Brush.Color:=rgb(247,247,239);
if ((State = [gdSelected])or(State=[gdSelected,gdFocused]))then
with TDBGridEH(Sender) do
begin
Canvas.Brush.color:=rgb(210,234,249);
Canvas.Font.Color:=clBlack;
Canvas.Pen.Mode:=pmMask;
DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
end;
我写成过程 在共公单元
错误提示: [Error] pubfunc.pas(30): Undeclared identifier: 'TRect'
[Error] pubfunc.pas(592): Undeclared identifier: 'rgb'
我引用的单元
uses
unit1,ADODB,Un_datamodule,StdCtrls,SysUtils,Dialogs,DBGridEhImpExp,
GridsEh,DBGridEh,Classes,Graphics;
我是实现dbgrideh的颜色的,因为多个窗口用到,就想写个公共过程
 
uses
Windows;
 
恩 可是现在又出现这个错误
[Error] pubfunc.pas(590): Missing operator or semicolon
 
procedure DBGridEhDrawColumnCell;
var
Sender:TObject;Rect:TRect;DataCol:Integer;Column:TColumnEh;State:TGridDrawState;
begin
if (TDBGridEH(Sender).DataSource.DataSet.RecNo Mod 2=0) then
TDBGridEH(Sender).Canvas.Brush.Color:=rgb(255,245,249)
else
TDBGridEH(Sender).Canvas.Brush.Color:=rgb(247,247,239);
if ((State = [gdSelected])or(State=[gdSelected,gdFocused]))then
with TDBGridEH(Sender) do
begin
Canvas.Brush.color:=rgb(210,234,249);
Canvas.Font.Color:=clBlack;
Canvas.Pen.Mode:=pmMask;
DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
end;
现在不会了 我改了下参数 可是我调用时就不行了 提示地址错误
 
Sender:TObject;Rect:TRect;DataCol:Integer;Column:TColumnEh;State:TGridDrawState;
这句放在begin end 里面.试试,在var里重新定义一个DBGRIEDEH,
 
procedure Tcgstore_find.DBGridRePaint(DB1:TDBGridEH;
const Rect: TRect; DataCol: Integer; Column: TColumnEh;
State: TGridDrawState);
begin
case db1.DataSource.DataSet.RecNo mod 2=0 of
True: Db1.Canvas.Brush.Color:=rgb(255,245,249);
False: Db1.Canvas.Brush.Color:=rgb(247,247,239);
end;
if ((State = [gdSelected]) or (State=[gdSelected,gdFocused])) then
with db1 do
begin
Canvas.Brush.color:=rgb(210,234,249);
Canvas.Font.Color:=clBlack;
Canvas.Pen.Mode:=pmMask;
DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
end;
提示错误: [Error] Un_cgstore_find.pas(377): Incompatible types
 
DefaultDrawColumnCell(Rect,DataCol,Column,State);
就是这一行
 
procedure SetGridEHColor1(Sender: TObject;const Rect: TRect; DataCol: Integer; Column: TColumnEh;
State: TGridDrawState);
begin
with Tdbgrideh(Sender) do //选中状态
begin
if gdSelected in State then
begin
Canvas.Brush.Color :=$00FFECD9;
Canvas.Font.Color :=clBlack;
end;
DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
end;
 
接受答案了.
 
后退
顶部