在onDrawdatacell中:
var left:integer;
begin
if 条件满足 then
begin
DBGRID1.Canvas.brush.color:=CLRED;
DBGRID1.Canvas.fillrect(rect);
case Field.Alignment of
taLeftJustify: Left := Rect.Left + 2;
taRightJustify: Left := Rect.Right - Canvas.TextWidth-(field.asstring) - 3;
end;
Dbgrid1.Canvas.TextRect (Rect,left,Rect.top+2,field.asstring);
end;
end;