Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 02-04-2014
Avatar de Angel.Matilla
Angel.Matilla Angel.Matilla is offline
Miembro
 
Registrado: ene 2007
Posts: 1.350
Poder: 19
Angel.Matilla Va por buen camino
TCheckListBox: Colores individuales

¿Se podría hacr en un TCheckListBox que cada un de los ítemes tuviera un color de fondo diferente?
Responder Con Cita
  #2  
Antiguo 02-04-2014
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.275
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
Cita:
Empezado por Angel.Matilla Ver Mensaje
¿Se podría hacr en un TCheckListBox que cada un de los ítemes tuviera un color de fondo diferente?
La forma de hacerlo es pintando de forma "manual" los items de la lista
Coloca la propiedad Style a lbOwnedDrawFixed
En el procedimiento OnDrawItem del CheckListBox coloca el siguiente código:

Código Delphi [-]
procedure Tt.CheckListBox1DrawItem(Control: TWinControl; Index: Integer;
                                   Rect: TRect; State: TOwnerDrawState);
begin

  if (index = 0) then begin
    CheckListBox1.Canvas.Brush.Color := clYellow;
  end
  else if (index = 1) then begin
    CheckListBox1.Canvas.Brush.Color := clInfoBk;
  end
  else if (index = 2) then begin
    CheckListBox1.Canvas.Brush.Color := clMoneyGreen;
  end
  else if (index = 3) then begin
    CheckListBox1.Canvas.Brush.Color := clBtnFace;
  end;

  // Fondo
  CheckListBox1.Canvas.FillRect(Rect);
  // Texto
  CheckListBox1.Canvas.TextOut(Rect.Left, Rect.Top, CheckListBox1.Items[index]);
end;

Deberás añadir cambios para el color del texto y tener en cuenta cuando el elemeno está seleciconado (parámetro State), pero este es un principio...
__________________
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
  #3  
Antiguo 02-04-2014
Avatar de Angel.Matilla
Angel.Matilla Angel.Matilla is offline
Miembro
 
Registrado: ene 2007
Posts: 1.350
Poder: 19
Angel.Matilla Va por buen camino
Gracias por la ayuda.
Responder Con Cita
Respuesta



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
TCheckListBox inquietud andressanchez Varios 2 14-06-2012 22:21:33
Manejo de celdas individuales en TDrawGrid protector2020 Gráficos 1 07-05-2008 17:19:49
Hint para items individuales de un TCheckBox Lord Delfos Varios 2 26-02-2008 23:36:50
tchecklistbox argel Varios 5 27-05-2006 00:08:06
Ayuda con TCheckListBox astur_racing Varios 4 04-09-2004 19:30:34


La franja horaria es GMT +2. Ahora son las 09:55:18.


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