Ver Mensaje Individual
  #1  
Antiguo 21-06-2011
adrall adrall is offline
Miembro
 
Registrado: ene 2007
Posts: 99
Reputación: 20
adrall Va por buen camino
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.

Última edición por adrall fecha: 21-06-2011 a las 12:10:21.
Responder Con Cita