Utilizo el siguiente codigo para alinear texto en un StringGrid:
Código:
procedure TFormComandes.PartidesGridDrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
txt:String;
i: integer;
begin
if ACol = 2 then //* Columna a alinear *//
if ARow > 0 then //* Para no alinear la línea de los títulos *//
if PartidesGrid.Cells[ ACol, ARow ] <> '' then
begin
txt := PartidesGrid.Cells[ ACol, ARow ];
with PartidesGrid do
with Canvas,Rect do
begin
i := Right-TextWidth( txt + ' ' );
Canvas.FillRect( Rect );
Canvas.TextOut( i, Top + 1, txt );
end;
end;
end;
end;
Ahora en Delphi XE funciona correctamente EXCEPTO si la celda está seleccionada, en este caso dibuja el texto dos veces, alineado y sin
alinear, parece como si ejecutara tanto el evento capturado como la rutina por defecto. Se os ocurre alguna solución a este comportamiento tan extraño?
OBSERVACION: Este hecho solo ocurre si cambio el StringGrid.DrawingStyle a gdsGradient.