Link to home
Start Free TrialLog in
Avatar of zattz
zattz

asked on

dbgrid colour of cell when editing

Hi

When I edit a cell on a grid it's background color is white. How do I change the background colour when editing?
Avatar of cula99
cula99

Try this:

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
  if (gdFocused in State) and ((Sender as TDBGrid).DataSource.DataSet.State=dsEdit) then
    begin
      DBGrid1.Canvas.Font.Color:=clBlack;
      DBGrid1.Canvas.Brush.Color:=clYellow;
      DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
    end
  else
  DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
ASKER CERTIFIED SOLUTION
Avatar of Russell Libby
Russell Libby
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zattz

ASKER

Excellent. Thanks a lot :)