Hola ecfisa.
Muchas gracias por responder y perdona por la tardanza en responder.
Hasta ahora no he podido probar tu código.
Me ha funcionado muy bien y solo he tenido que modificar un poco para
que me funcionara como quería.
Al final el código a quedado así:
Código Delphi
[-]procedure TBusca_Socios.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
const
FLAGS = DT_SINGLELINE or DT_VCENTER or DT_CENTER;
var
R: TRect;
begin
R:= Rect;
if Column.Field = DM.SociosTIPO_CUOTA then
if DM.SociosTIPO_CUOTA.AsString = 'EXCEDENCIA' then
begin
if (gdFocused in State) then DBGrid1.Canvas.Brush.Color := clRed
else DBGrid1.Canvas.Brush.Color := clYellow;
DBGrid1.DefaultDrawDataCell(rect,Column.Field,State);
end;
with TDBGrid(Sender).Canvas do
begin
if Column.Field = DM.SociosESTADO then
if DM.SociosESTADO.AsString = 'B' then
begin
if (gdFocused in State) then Brush.Color := clRed
else Brush.Color := clGray;
FillRect(Rect);
DrawText(Handle, PChar(Column.Field.AsString),-1, R, FLAGS);
end;
end;
end;
De esta manera me queda el texto centrado cuando cambia el estado y
además cuando la celda queda seleccionada cambia al color rojo.
Un saludo y gracias nuevamente.