Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 10-03-2011
ander ander is offline
Miembro
 
Registrado: may 2003
Posts: 56
Poder: 21
ander Va por buen camino
Cambiar fuente de texto en celdas de StringGrid

Hola a todos.
Podria decirme alguien, como podria cambiar en un StringGrid y en una columna determinada,el color de la celda y el tipo de texto.
por ej. uso esto:
-----------------------------------------------------------------
Código Delphi [-]
procedure TForm1.StringGridDrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
var
  TheRect :TRect;
begin
  if ACol=3 then
  begin
    TheRect :=StringGrid.CellRect(ACol,Arow);
    StringGrid.Canvas.TextRect(TheRect,1,1,'Hola');
    StringGrid.Canvas.brush.Color := clred;
    StringGrid.Canvas.FrameRect(TheRect);
  end;
end;
----------------------------------------------------------------
No hay manera de escribir el texto dentro de la celda,pero puedo colorearlo.
Gracias de antemano

Última edición por ecfisa fecha: 11-03-2011 a las 02:16:19. Razón: ETIQUETAS DELPHI
Responder Con Cita
  #2  
Antiguo 10-03-2011
Avatar de Chris
[Chris] Chris is offline
Miembro Premium
 
Registrado: abr 2007
Ubicación: Jinotepe, Nicaragua
Posts: 1.678
Poder: 18
Chris Va por buen camino
Con el objeto canvas del StringGrid, por ejemplo así:

Código Delphi [-]
StringGrid.Canvas.Font.Color := clRed;
StringGrid.Canvas.Font.Font = 'Arial';
// para el fondo
StringGrid.Canvas.Brush.Color := clYellow
StringGrid.Canvas.Brush.Style := bsSolid;
// etc...

Saludos!
__________________
Perfil Github - @chrramirez - Delphi Blog - Blog Web
Responder Con Cita
  #3  
Antiguo 11-03-2011
ander ander is offline
Miembro
 
Registrado: may 2003
Posts: 56
Poder: 21
ander Va por buen camino
Cambiar fuente de texto en celdas de StringGrid

Gracias por la respuesta, pero por más que cambio las posiciones y demas ,no hay manera de que vea en la celda y dentro del rectangulo creado el texto,y no se que hacer.
Ahora mismo, lo he dejado así y me escribe un rectángulo dentro de la celda pero no aparece el texto.
Código Delphi [-]
procedure TForm1.StringGridDrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
var
  TheRect :TRect;
begin
  if ACol=3 then
  begin
    TheRect :=StringGrid.CellRect(ACol,Arow);
    StringGrid.Canvas.Font.Color := clRed;
    StringGrid.Canvas.font.Style := Entrada_Datos.canvas.Font.Style + [fsBold];
    StringGrid.Canvas.Brush.Color := clYellow ;
    StringGrid.Canvas.Brush.Style := bsSolid;
    StringGrid.Canvas.TextRect(TheRect,1,1,'Hola');
    StringGrid.Canvas.FrameRect(TheRect);
  end;
end;

Última edición por ecfisa fecha: 11-03-2011 a las 15:44:18. Razón: ETIQUETAS DELPHI
Responder Con Cita
  #4  
Antiguo 11-03-2011
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.233
Poder: 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
En mi web hay una entrada antigua titulada Color y alineación en celdas de un StringGrid, donde puedes ver el código del evento OnDrawCell; En ese caso se cambian los colores y se pinta el texto (de forma similar a como lo haces tú).
Si añades el cambio de fuente debería fucionar sin problemas.

Échale un vistazo al código y prueba a cambiarlo.
__________________
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
  #5  
Antiguo 11-03-2011
ander ander is offline
Miembro
 
Registrado: may 2003
Posts: 56
Poder: 21
ander Va por buen camino
Gracias por el ejemplo,es todo lo que necesitaba
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Copiar Y Pegar texto en las celdas de un StringGrid rgstuamigo OOP 2 01-12-2008 14:55:51
Multiplicar 2 celdas de un stringgrid Elite237 OOP 3 11-11-2008 03:02:59
StringGrid + celdas Makiley Varios 4 01-02-2006 14:01:15
combinar celdas de StringGrid VRO Varios 2 21-04-2005 09:02:16
Cambiar la fuente, el color del texto y su tamaño en un tmemo gaska OOP 1 06-05-2004 20:09:02


La franja horaria es GMT +2. Ahora son las 19:01:21.


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