Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   Problema al alinear texto en StringGrid en XE (https://www.clubdelphi.com/foros/showthread.php?t=74455)

adrall 21-06-2011 11:58:05

Problema al alinear texto en StringGrid en XE
 
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.


La franja horaria es GMT +2. Ahora son las 00:45:59.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi