Ir al contenido


Foto

[RESUELTO] El extraño caso de la etiqueta (TLabel) invisible.


  • Por favor identifícate para responder
4 respuestas en este tema

#1 TiammatMX

TiammatMX

    Advanced Member

  • Miembros
  • PipPipPip
  • 1.750 mensajes
  • LocationUniverso Curvo\Vía Láctea\Sistema Solar\Planeta Tierra\América\México\Ciudad de México\Xochimilco\San Gregorio Atlapulco\Home

Escrito 10 noviembre 2011 - 01:19

Buena tarde, jóvenes y jóvenas ilustres de DelphiAccess...

Les platico el caso. Tengo una forma que contiene un TScrollBox, y que será llenada con TLabel's y TRadioButton's de acuerdo al contenido de un TADOQuery. Tengo éste código en Delphi 6:



delphi
  1.     if RecordCount > 0 then
  2.     begin
  3.       First;
  4.       sGrp := FieldByName('C54_GRUPO_STR').AsString;
  5.       with TLabel.Create(scrllboxLlenar) do
  6.       begin
  7.         Left := 0;
  8.         Top := iVlrRngln;
  9.         AutoSize := False;
  10.         Width := scrllboxLlenar.Width - 4;
  11.         Color := StringToColor(FieldValues['C54_COLOR_FONDO']);
  12.         Font.Color := StringToColor(FieldValues['C54_COLOR_FUENTE']);
  13.         Alignment := taCenter;
  14.         Visible := True;
  15.         Caption := sGrp;
  16.       end;
  17.  
  18.       while NOT Eof do
  19.       begin
  20.         if FieldByName('C54_GRUPO_STR').AsString <> sGrp then
  21.         begin
  22.           iVlrRngln := iVlrRngln + 20;
  23.           sGrp := FieldByName('C54_GRUPO_STR').AsString;
  24.           with TLabel.Create(scrllboxLlenar) do
  25.           begin
  26.             Left := 0;
  27.             Top := iVlrRngln;
  28.             AutoSize := False;
  29.             Width := scrllboxLlenar.Width - 4;
  30.             Color := StringToColor(FieldValues['C54_COLOR_FONDO']);
  31.             Font.Color := StringToColor(FieldValues['C54_COLOR_FUENTE']);
  32.             Alignment := taCenter;
  33.             Visible := True;
  34.             Caption := sGrp;
  35.           end;
  36.         end;
  37.  
  38.         Next;
  39.       end;
  40.     end;



Y aquí es donde viene el "pero" y la raíz del problema. El tal TScrollBox al momento de ser visible en la forma, ¡¡ESTÁ VACÍO!!, o aparenta estarlo. No se ve ninguna de las TLabel's que SUPUESTAMENTE ya fueron creadas y añadidas al TScrollBox a pesar que TODO el código ejecuta perfectamente.

¿Alguna idea, alguna solución que puedan aportarme? Agradeciendo de antemano sus colaboraciones...
  • 0

#2 egostar

egostar

    missing my father, I love my mother.

  • Administrador
  • 14.448 mensajes
  • LocationMéxico

Escrito 10 noviembre 2011 - 01:33

Hola

Y no hace falta asignar el Parent de los Labels ?

Salud OS
  • 0

#3 eduarcol

eduarcol

    Advanced Member

  • Administrador
  • 4.483 mensajes
  • LocationVenezuela

Escrito 10 noviembre 2011 - 01:38

Te falto
Parent := scrllboxLlenar


En el bloque donde creas los TLabel
  • 0

#4 TiammatMX

TiammatMX

    Advanced Member

  • Miembros
  • PipPipPip
  • 1.750 mensajes
  • LocationUniverso Curvo\Vía Láctea\Sistema Solar\Planeta Tierra\América\México\Ciudad de México\Xochimilco\San Gregorio Atlapulco\Home

Escrito 10 noviembre 2011 - 01:52

Pues sí..., faltaba el Parent para ambos tipos de componentes...

El código, corregido y aumentado, corriendo perfectamente...




delphi
  1.     if RecordCount > 0 then
  2.     begin
  3.       First;
  4.       sGrp := FieldByName('C54_GRUPO_STR').AsString;
  5.       with TLabel.Create(scrllboxLlenar) do
  6.       begin
  7.         Left := 0;
  8.         Parent := scrllboxLlenar;
  9.         Top := iVlrRngln;
  10.         AutoSize := False;
  11.         Width := scrllboxLlenar.Width - 4;
  12.         Color := StringToColor(FieldValues['C54_COLOR_FONDO']);
  13.         Font.Color := StringToColor(FieldValues['C54_COLOR_FUENTE']);
  14.         Alignment := taCenter;
  15.         Visible := True;
  16.         Caption := sGrp;
  17.       end;
  18.  
  19.       while NOT Eof do
  20.       begin
  21.         if FieldByName('C54_GRUPO_STR').AsString <> sGrp then
  22.         begin
  23.           iVlrRngln := iVlrRngln + 20;
  24.           sGrp := FieldByName('C54_GRUPO_STR').AsString;
  25.           with TLabel.Create(scrllboxLlenar) do
  26.           begin
  27.             Left := 0;
  28.             Parent := scrllboxLlenar;
  29.             Top := iVlrRngln;
  30.             AutoSize := False;
  31.             Width := scrllboxLlenar.Width - 4;
  32.             Color := StringToColor(FieldValues['C54_COLOR_FONDO']);
  33.             Font.Color := StringToColor(FieldValues['C54_COLOR_FUENTE']);
  34.             Alignment := taCenter;
  35.             Visible := True;
  36.             Caption := sGrp;
  37.           end;
  38.         end;
  39.  
  40.         iVlrRngln := iVlrRngln + 20;
  41.         with TRadioButton.Create(scrllboxLlenar) do
  42.         begin
  43.           Left := 0;
  44.           Parent := scrllboxLlenar;
  45.           Top := iVlrRngln;
  46.           AutoSize := False;
  47.           Width := scrllboxLlenar.Width - 4;
  48.           Visible := True;
  49.           Caption := FieldByName('C54_ETAPA_STR').AsString;;
  50.         end;
  51.  
  52.         Next;
  53.       end;
  54.     end;




Gracias, muchachos...  (b) (b) (b) (b) (b) (b) (b)
  • 0

#5 eduarcol

eduarcol

    Advanced Member

  • Administrador
  • 4.483 mensajes
  • LocationVenezuela

Escrito 10 noviembre 2011 - 01:55

Se coloca como resuelto?


  • 0




IP.Board spam blocked by CleanTalk.