Link to home
Start Free TrialLog in
Avatar of ramoreia
ramoreia

asked on

DBGrid Color Change

I need that when the user enters a row in the DBGrid that row changes to a different color like 'clInfoBk'. I need the whole row and not just the Collumn Cell.
Avatar of mokule
mokule
Flag of Poland image

If You do not need dgEditing Option for dbgrid You can set
dgRowSelect to True
dbgrid1.columns[1].color := clInfoBk;


Avatar of Ferruccio Accalai
Set dgRowSelect to true in Option then

procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
  Field: TField; State: TGridDrawState);
begin
if gdselected in state then
    TDBGrid(Sender).Canvas.Brush.Color :=  clInfoBk
    else
    TDBGrid(Sender).Canvas.Brush.Color := clWindow;
  TDBGrid(Sender).DefaultDrawDataCell(Rect, Field, State);
end;
ASKER CERTIFIED SOLUTION
Avatar of mokule
mokule
Flag of Poland 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