// Enter the following code in the TDBGrid's OnDrawDataCell event:
Procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
If gdFocused in State then
with (Sender as TDBGrid).Canvas do
begin
Brush.Color := clRed;
FillRect(Rect);
TextOut(Rect.Left, Rect.Top, Field.AsString);
end;
end;
// Set the Default drawing to true. With this, it only has to draw the
// highlighted cell. If you set DefaultDrawing to false, you must draw all
// the cells yourself with the canvas properties.