6
I’m painting the lines of a dbgrid, in the Delphi-xe3, but my condition to paint the selected line is not working properly.
When selecting the row (set the focus) only the first column is being painted. Example:
The estate Options
, dgRowSelect
is set as True
.
My code to paint the lines and paint the line when it is selected, as found in the web example:
procedure TFrmCadTerminal.dbgTerminaisDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
inherited;
if cdsTerminal.IsEmpty then exit;
if cdsTerminalAcess_TerE.AsString <> 'S' then
begin
if gdFocused in State then
begin
dbgTerminais.Canvas.Brush.Color := clRed;
dbgTerminais.Canvas.Font.Color := clWhite;
dbgTerminais.Canvas.FillRect(Rect);
dbgTerminais.DefaultDrawDataCell(Rect, Column.Field, State);
end
else
begin
dbgTerminais.Canvas.Brush.Color := clMaroon;
dbgTerminais.Canvas.Font.Color := clWhite;
dbgTerminais.Canvas.FillRect(Rect);
dbgTerminais.DefaultDrawDataCell(Rect, Column.Field, State);
end;
end;
end;
I would like the entire line to be painted the same color when selecting it. How to solve this?
Thanks for the tip, saved me the day.
– Aleandro