Ver Mensaje Individual
  #2  
Antiguo 13-05-2005
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - Espańa
Posts: 18.333
Reputación: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Utiliza el evento OnDrawCell (para ambas cosas). Busca en los foros "StringGrid Color" (sin las comillas), verás como es un tema que ya se ha tratado.

El tema de la alineación es similar (OnDrawCell); Aquí tienes un ejemplo:

Código Delphi [-]
 procedure TFormStringGrid.StringGrid1DrawCell(Sender: TObject; ACol,
                     ARow: Integer; Rect: TRect; State: TGridDrawState);
 
   //···············································································
   procedure WriteText(StringGrid: TStringGrid; ACanvas: TCanvas; const ARect: TRect;
     const Text: string; Format: Word);
   const
     DX = 2;
     DY = 2;
   var
     S: array[0..255] of Char;
     B, R: TRect;
   begin
     with Stringgrid, ACanvas, ARect do
     begin
       case Format of
         DT_LEFT: ExtTextOut(Handle, Left + DX, Top + DY,
             ETO_OPAQUE or ETO_CLIPPED, @ARect, StrPCopy(S, Text), Length(Text), nil);
 
         DT_RIGHT: ExtTextOut(Handle, Right - TextWidth(Text) - 3, Top + DY,
             ETO_OPAQUE or ETO_CLIPPED, @ARect, StrPCopy(S, Text),
             Length(Text), nil);
 
         DT_CENTER: ExtTextOut(Handle, Left + (Right - Left - TextWidth(Text)) div 2,
             Top + DY, ETO_OPAQUE or ETO_CLIPPED, @ARect,
             StrPCopy(S, Text), Length(Text), nil);
       end;
     end;
   end;
   //···············································································
   procedure Display(StringGrid: TStringGrid; const S: string; Alignment: TAlignment);
   const
     Formats: array[TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER);
   begin
     WriteText(StringGrid, StringGrid.Canvas, Rect, S, Formats[Alignment]);
   end;
   //···············································································
 begin
 
   // La columna 0 a la derecha
   if ACol = 0 then begin
     Display(StringGrid1, StringGrid1.Cells[ACol, ARow], taRightJustify);
   end;
 
   // La columna 1 a la centrada
   if ACol = 1 then begin
     Display(StringGrid1, StringGrid1.Cells[ACol, ARow], taCenter);
   end;
 
   // La primera fila (de titulos centrada)
   if ARow = 0 then begin
     Display(StringGrid1, StringGrid1.Cells[ACol, ARow], taCenter);
   end;
 
 end;
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita