procedure Tinfo.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if query1.FieldByName(’all’).asstring>40’ then begin dbgrid1.Canvas.Font.Color:=clred; dbgrid1.Canvas.Brush.color:=clyellow; end else begin dbgrid1.Canvas.Font.Color:=clblue; dbgrid1.Canvas.Brush.color:=clyellow; end;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if query1.FieldByName(’all’).asstring>40’ then
begin
dbgrid1.Canvas.Font.Color:=clred;
dbgrid1.Canvas.Brush.color:=clyellow;
end
else
begin
dbgrid1.Canvas.Font.Color:=clblue;
dbgrid1.Canvas.Brush.color:=clyellow;
end;
dbgrid1.DefaultDrawColumnCell(rect,datacol,column,state);
end;
替你解决最主要的问题吧,变为红色:
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if adoquery1.FieldByName('num').Asinteger<0 then DBGrid1.Canvas.Font.Color:=clRed;
DBGrid1.DefaultDrawColumnCell(rect,DataCol,column,state);
end;