J
jony1
Unregistered / Unconfirmed
GUEST, unregistred user!
我在dbgrideh的DBGridEh1DrawColumnCell加入以下语句,以为能改变每行的颜色,
可是不行
为啥?
procedure TForm1.DBGridEh1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumnEh;
State: TGridDrawState);
begin
if not (gdFixed in State) then
begin
with DBGridEh1.Canvas do
begin
if DataModule1.Query1.fieldbyname('余额')>0 then
Brush.Color := clGreen
else
Brush.Color:=clred;
FillRect(Rect);
Font.Color:=clblack;
TextOut(Rect.Left, Rect.Top, Field.AsString);
end;
end;
end;
end.
可是不行
为啥?
procedure TForm1.DBGridEh1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumnEh;
State: TGridDrawState);
begin
if not (gdFixed in State) then
begin
with DBGridEh1.Canvas do
begin
if DataModule1.Query1.fieldbyname('余额')>0 then
Brush.Color := clGreen
else
Brush.Color:=clred;
FillRect(Rect);
Font.Color:=clblack;
TextOut(Rect.Left, Rect.Top, Field.AsString);
end;
end;
end;
end.