Dynamically Add Tabs to Tabstrip
Hello,
In my project , i need to display a TabStrip with variable number of Tabs. For example with response to one command , the tabStrip will conatin 4 tabs , with another 5 tabs etc . Due to the complexity of the controls in the tab , i wish to have them as separte forms and at runtime add them to the tabstrip.
Can anyone help me out with a solution.
Thanks,
Thiyagarajan
Re: Dynamically Add Tabs to Tabstrip
Here is a trick that I used in one of the applications I made for the company. It is nice to know the number of tabs upfront. Say there will be a max of 9 different tabs. So in the tabcontrol set to 9 tabs, rows = 1, label all your tabs. In the UI create objects on each tab.
In the code, it is best to use constants for each tab instead of index numbers. When the form loads, hide all tabs usings Tab(INFO).Visible = True. As you go in the program set the tabs you need to show by changing the visible to true.
There will be a large amount of coding for each tab in a subroutine. I use select case statements.
Select Case TabIndex
Case INFO
'do whatever object on tab needs to do.
'or anything special here.
Case ADDRESS
'do whatever needed here
Case CITY
'do whatever needed here
End Select
Of course this is a mock stuff but you should get the idea I am talking about if your username is AdvancedUI. ;)
Re: Dynamically Add Tabs to Tabstrip
Here is a trick that I used in one of the applications I made for the company. It is nice to know the number of tabs upfront. Say there will be a max of 9 different tabs. So in the tabcontrol set to 9 tabs, rows = 1, label all your tabs. In the UI create objects on each tab.
In the code, it is best to use constants for each tab instead of index numbers. When the form loads, hide all tabs usings Tab(INFO).Visible = True. As you go in the program set the tabs you need to show by changing the visible to true.
There will be a large amount of coding for each tab in a subroutine. I use select case statements.
Select Case TabIndex
Case INFO
'do whatever object on tab needs to do.
'or anything special here.
Case ADDRESS
'do whatever needed here
Case CITY
'do whatever needed here
End Select
Of course this is a mock stuff but you should get the idea I am talking about. ;)
Re: Dynamically Add Tabs to Tabstrip
The problem is to avoid loading all the 9 forms .I want to load only one form ( the selected item in the tab ) . I have all the data for the controls in my class objects . So there is no point in loading all the panels.
Also the size of each tabs is different.That also poses one more problem.So when user selects one tab, i should show the form on the tab and resize the tab to the size of the current tab.
Now you know this comes in the AdvancedUI category!!
Re: Dynamically Add Tabs to Tabstrip
Sorry for being gone too long. I had all the objects designed on all the tabs individually. But your case is using forms instead, not sure how to load it separately especially with tabs. I founded an article in VBPJ written by Dan Appleton something about dynamically loading forms. It was written a few years ago. But when I found it, I gave it to a co-worker of mine for a project we had. He applied the same concept and said it worked. It also kept the memory size under control.
You can go over to VBPJ website and do a search on it. I know it is a few years old and VBPJ will make you have to pay membership to access the article. You can probably find it using the trial membership.