Board index » cppbuilder » New Tab Sheet in Page Control

New Tab Sheet in Page Control

Hi,
I need TTabSheets to be created dynamically when the user
performs a certain action.  I have tried to do this on my own but
can't figure it out.  

Anyone know how to create one outside of design time?

Armond Carroll

 

Re:New Tab Sheet in Page Control


Thanks tons, Hans.

The problem with mine was I was using:
TTabSheet *TabSheet = new TTabSheet;
rather than adding (this)

Thanks Again,
Armond Carroll

Quote
Hans Galema <j.m.gal...@maartens.nl> wrote:
>Like this:

>void __fastcall TForm1::AddTabSheetButtonClick(TObject *Sender)
>{
>TTabSheet * TabSheet = new TTabSheet ( this );

>if ( ! TabSheet ) return;

>TabSheet->PageControl = PageControl1;
>TabSheet->Parent = PageControl1;
>TabSheet->Caption = String ("New tabsheet" );
>TabSheet->TabVisible = TRUE;
>TabSheet->Visible = TRUE;
>PageControl1->ActivePage=TabSheet;

>/* Bonus: Place a TButton on the TabSheet */

>TButton *Button = new TButton ( this );
>Button->Caption = "New button" ;
>Button->Width = 150;
>Button->Left = 100;
>Button->Top = 50;
>Button->Parent = TabSheet;
>}

>Hans.

>Armond Carroll wrote:

>> I need TTabSheets to be created dynamically when the user
>> performs a certain action.

Re:New Tab Sheet in Page Control


All you have to to is instantiate a new Tab.
For instance, I remember seeing this exact
problem with a solution on Borland Somewhere.

You must create your tab sheet, then instantiate
a new tab with the TTabSheet as the owner.

Eg.
TTabSheeet *myTabSheet = new TTabSheet(self)

TTab *newTab = new TTab(myTabSheet);

Something like that, I can't remember exactly but that should get you
started.

Quote
Armond Carroll wrote:
> Hi,
> I need TTabSheets to be created dynamically when the user
> performs a certain action.  I have tried to do this on my own but
> can't figure it out.  

> Anyone know how to create one outside of design time?

> Armond Carroll

--
------------
|~ Shadow ~|
------------

Other Threads