Board index » delphi » Dynamic tabsheets + panels

Dynamic tabsheets + panels

Hi

I am creating objects at runtime onto a tabsheet which is also created at
runtime.

I can add stuff to the tabsheet quite easily.

However I want to be able to add a button at runtime to a panel which has
been created on the tabsheet at runtime.

So that the button's parent is the panel on the tabsheet.

To create the panel I am using the following:

with TPanel.Create(Tabsheet) do
   begin
       Parent  := TabSheet;
       Name    := 'Panel1';
       Left    := 200;
       Top     := 175;
       Width   := 200;
       Height  := 200;
   end;

and to create the button I use:

with TButton.Create(TabSheet) do
   begin
      Parent  := Tabsheet;
      Name    := 'Button1';
      Left    := 100;
      Top     := 50;
      Caption := 'Test';
    end;

What should I be putting in the parent part of the button1 create code to
make it belong to panel1.

Cheers

--
Dirk            dirk @bigger.com

 

Re:Dynamic tabsheets + panels


The easiest thing to do would be to use a temporary variable to Panel1
that you can reuse in the creation of the button:

var
  MyPanel: TPanel;
begin
  MyPanel := TPanel.Create(Tablsheet);
  with MyPanel do
   begin
       Parent  := TabSheet;
       Name    := 'Panel1';
       Left    := 200;
       Top     := 175;
       Width   := 200;
       Height  := 200;
   end;

and to create the button I use:

with TButton.Create(TabSheet) do
   begin
      Parent  := MyPanel;
      Name    := 'Button1';
      Left    := 100;
      Top     := 50;
      Caption := 'Test';
    end;

 -- x

Xavier Pacheco (TeamB)
Xapware Technologies Inc.
www.xapware.com
www.xapxone.com

------------------------------------------------
Sorry but TeamB cannot answer support
questions received via email.

Re:Dynamic tabsheets + panels


In article <8636at8cfp0h8906k5pef4obgmknvs6...@4ax.com>,
xav...@xapware.com says...

Quote
> The easiest thing to do would be to use a temporary variable to Panel1
> that you can reuse in the creation of the button:

> var
>   MyPanel: TPanel;
> begin
>   MyPanel := TPanel.Create(Tablsheet);
>   with MyPanel do
>    begin
>        Parent  := TabSheet;
>        Name    := 'Panel1';
>        Left    := 200;
>        Top     := 175;
>        Width   := 200;
>        Height  := 200;
>    end;

> and to create the button I use:

> with TButton.Create(TabSheet) do
>    begin
>       Parent  := MyPanel;
>       Name    := 'Button1';
>       Left    := 100;
>       Top     := 50;
>       Caption := 'Test';
>     end;

>  -- x

> Xavier Pacheco (TeamB)
> Xapware Technologies Inc.
> www.xapware.com
> www.xapxone.com

Thanks very much for replying, I appreciate it greatly.

--
Dirk            dirk @bigger.com

Other Threads