(1)分行不同颜色设置;在DBGridEh1DrawColumnCell中写;
if ADOQuery1.RecNo mod 2=0 then
begin
DBGridEh1.Canvas.
Font.Color := clRed;
DBGridEh1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end
else begin
DBGridEh1.Canvas.
Font.Color := clGreen;
DBGridEh1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
(2)分行不同背景颜色设置;在DBGridEh1DrawColumnCell中写;
if ADOQuery1.RecNo mod 2=0 then
begin
DBGridEh1.Canvas.
Brush.Color := clRed;
DBGridEh1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end
else begin
DBGridEh1.Canvas.
Brush.Color := clGreen;
DBGridEh1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
(3)符合条件的单元格颜色或者背景颜色设置;在DBGridEh1DrawColumnCell中写;
if
Column.FieldName='价格' then
begin
if
ADOQuery1.FieldByName('价格').AsFloat<0 then
begin
DBGridEh1.Canvas.Font.Color := clRed;
DBGridEh1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;
发表于 @ 2004年10月27日 11:00:00|评论(loading...)|编辑