Board index » delphi » Create TTabSheet in TPageControl at run-time (Delphi 2.x)

Create TTabSheet in TPageControl at run-time (Delphi 2.x)

Can anyone help me with my 'shitty' problem (I have been sitting looking
at this 'easy' problem for about 1 and a half hour - without finding the
right way to do it):

How do I create TTabSheets in a TPageControl at run-time, and at the
same time create a button or label on every page?

Hope to hear from someone soon.

John Foldager
fairn...@post2.tele.dk

 

Re:Create TTabSheet in TPageControl at run-time (Delphi 2.x)


Quote
John Foldager wrote:

> Can anyone help me with my 'shitty' problem (I have been sitting looking
> at this 'easy' problem for about 1 and a half hour - without finding the
> right way to do it):

> How do I create TTabSheets in a TPageControl at run-time, and at the
> same time create a button or label on every page?

> Hope to hear from someone soon.

> John Foldager
> fairn...@post2.tele.dk

procedure TForm1.Button1Click(Sender: TObject);
var
TabSheet: TTabSheet;
begin
TabSheet:=TTabSheet.create(self);
TabSheet.PageControl:=PageControl1;
TabSheet.Caption:='Page 1';

with TButton.create(self) do {you may want to create a variable instead}
begin
  Parent:=TabSheet;
  Caption:='Button 1';
end;
end;

Other Threads