Criar Componente Dinamico Sobre Componente Dinamico

Delphi

18/09/2006

i: Integer;
PageControl1: TPageControl;
begin
PageControl1 := TPageControl.Create(Self);
PageControl1.Parent := Self;
PageControl1.Align := alClient;
For i := 1 to 10 do
begin
With TTabSheet.Create(PageControl1) do
begin
PageControl := PageControl1;
Name := ´TSQuestao´ + IntToStr(i);
Caption := IntToStr(i);
end;
end;

Com esta função acima eu crio um PageControl e 10 abas(TabSheet) tudo dinamicamente. Agora vem minha pergunta: Como faço para criar dentro de cada aba(TabSheet) uma Label dinamicamente?

Desde já obrigado.


Leufmt

Leufmt

Curtidas 0

Respostas

Rodc

Rodc

18/09/2006

Tente assim:
i: Integer; 
PageControl1: TPageControl; 
Tab: TTabSheet;
texto: TLabel;
begin 
  PageControl1 := TPageControl.Create(Self); 
  PageControl1.Parent := Self; 
  PageControl1.Align := alClient; 
  For i := 1 to 10 do 
  begin 
    // Cria a Aba
    Tab := TTabSheet.Create(PageControl1);
    With Tab do 
    begin 
      PageControl := PageControl1; 
      Name := ´TSQuestao´ + IntToStr(i); 
      Caption := IntToStr(i);
    end; 

    // Cria o Label na Aba
    Texto := TLabel.Create(Tab);
    Texto.Parent := Tab;
    Texto.Caption := ´Label´ + IntToStr(i);
  end;
end;



GOSTEI 0
Leufmt

Leufmt

18/09/2006

Muito obrigado colega. Era isso mesmo.


GOSTEI 0
POSTAR