procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if (Query2.FieldByName('a').AsDateTime <now or Query2.FieldByName('b').AsDateTime<now or Query2.FieldByName('c').AsDateTime<now) then
begin
DBGrid1.Canvas.Font.Color:= clred;
end
else
begin
if Query2.FieldByName('d').AsString='mm' then
begin
DBGrid1.Canvas.Font.Color:= clblue;
end
else
begin
DBGrid1.Canvas.Font.Color:= clwindowText;
end end;
dbGrid1.DefaultDrawColumnCell(rect, datacol, column, state);
end;调试会出错
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if (Query2.FieldByName('a').AsDateTime <now or Query2.FieldByName('b').AsDateTime<now or Query2.FieldByName('c').AsDateTime<now) then
begin
DBGrid1.Canvas.Font.Color:= clred;
end
else
begin
if Query2.FieldByName('d').AsString='mm' then
begin
DBGrid1.Canvas.Font.Color:= clblue;
end
else
begin
DBGrid1.Canvas.Font.Color:= clwindowText;
end end;
dbGrid1.DefaultDrawColumnCell(rect, datacol, column, state);
end;调试会出错
if (Query2.FieldByName('a').AsDateTime <now) or (Query2.FieldByName('b').AsDateTime <now) or (Query2.FieldByName('c').AsDateTime <now) then ...
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if (Query2.FieldByName('a').AsDateTime <now()) or (Query2.FieldByName('b').AsDateTime <now()) or
(Query2.FieldByName('c').AsDateTime <now() ) then
begin
DBGrid1.Canvas.Font.Color:= clred;
end else
begin
if Query2.FieldByName('d').AsString='mm' then
begin
DBGrid1.Canvas.Font.Color:= clblue;
end else
begin
DBGrid1.Canvas.Font.Color:= clwindowText;
end
end;
dbGrid1.DefaultDrawColumnCell(rect, datacol, column, state);
end;