Welcome! Log In Create A New Profile

Advanced

Creating Tabs dynamically

Posted by Gus 
Gus
Creating Tabs dynamically
July 15, 2021 12:23AM
Hello:
Is it possible to dynamically add a new tab to a TAB control via code?
I'm trying to use ControlClone like this;

ControlClone(TAB_Control[1], TAB_Control[2])

but I get error

Thanks
Gus
Al
Re: Creating Tabs dynamically
July 15, 2021 12:31AM
Hello Gus

And the error is ???

If you don't need many new tabs you could just create them before hand and hide and display as TabControl[2] visible = False or True as required

Regards
Al
Gus
Re: Creating Tabs dynamically
July 15, 2021 12:41AM
Hello Al:

This is the error I get:

The 'TAB_Dashboards[1]' object cannot be cloned.
Only the controls and the table columns can be cloned.


I'm using this code;
ControlClone(TAB_Dashboards[1], "New Tab")

trying to clone the first pane which already exists...

I'm already using the "Hiding" technique but I would like to get rid of a pre-fixed number of possible tabs....

Thanks
Gus
Al
Re: Creating Tabs dynamically
July 15, 2021 01:35AM
Hello Gus

I have never used ControlClone() before but I tried it out on a window with a tab control that has 6 tabs
The interesting thing is that the controlclone() function runs the tab init and other code before attempting to create the cloned tab.
Initially I placed the controlclone() function very early in the window init and it failed when processing the tab init code because other values were not available yet
I then placed it in the window "end of initialization" event and it worked ok. This would have been after all the existing controls were initialized.

I would experiment with the placement of the controlclone() command and have the debugger run on it when it activates to see what happens.

Regards
Al
Argus
Re: Creating Tabs dynamically
July 15, 2021 03:23AM
yes you can... You have to define the tab control as dynamic for that, and there are specific instructions:

[help.windev.com]
Al
Re: Creating Tabs dynamically
July 15, 2021 03:27AM
Hello Argus

That may be the case but when I ran my test it was on a normal tab not a dynamic one.

Regards
Al
Re: Creating Tabs dynamically
July 15, 2021 11:30AM
Hi,

I'm away from my Dev machine, but (apparently) you can convert it to dynamic using daynamictab property, then use TabOpen... and, this only works with WD.

Regards,
Darren.
Gus
Re: Creating Tabs dynamically
July 16, 2021 10:19PM
Thanks Darren.

I actually need it for Webdev.

I will continue using the "hidden" tabs for now...

Regards;
Gus
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: