把DBGrid.DefaultDrawing设成FALSE 在DBGRID的DrawColumnCell事件加入 if 你的条件 then begin DBGrid1.Canvas.Brush.Color := clRed; end else begin DBGrid1.Canvas.Brush.Color := clWhite; end; DBGrid.DefaultDrawColumnCell(Rect,DataCol,Column,State); 以前的帖子有很多这样的问题,可以自己看看。
在OnCalcCellColors事件中加入以下语句即可: if field.index = 你所要的字段位置 then ABrush.Color := 你所要的颜色;
在DBGRID的DrawColumnCell事件加入
if 你的条件 then
begin
DBGrid1.Canvas.Brush.Color := clRed;
end
else
begin
DBGrid1.Canvas.Brush.Color := clWhite;
end;
DBGrid.DefaultDrawColumnCell(Rect,DataCol,Column,State);
以前的帖子有很多这样的问题,可以自己看看。
if field.index = 你所要的字段位置 then
ABrush.Color := 你所要的颜色;