Add user control to new tab control

taz8020 used Ask the Experts™
Hi I have about 12 user controls, when someone clicks a button (which is in the left panel) i want to load the contol in the right panel showing the tab. If someone clicks another button it opens a new tab and put the control in that tab.

At the moment when someone clicks the button it just opens the usercontrol in the panel on the right. If they click a different button it loads the new control over the exiting one. All i want to do is as they open a new one, open it in a new tab so they can switch between tabs.

I know i could create a tabcontrol in design view and put all the controls on different tabs however some controls have a lot of data and I what to just load them as required.

Hope this makes sense.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Add a TabPage to your form and add your User Control to it....

        Dim tp As New TabPage
        With tp
            .Text = "Tab Text"
        End With



Thats great just what i need. Just a quick question how do I check if that tab already exits? and also if they click close how do I close a tab by name?
If you also set the Name property of the TabPage, you can use this to determine if a TabPage already exists....

        If Not Me.TabControl1.TabPages.ContainsKey("TabName") Then
            'add your tab page
        End If

To remove a Tab given a Name, you would use this....


Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!


You Are a star, thanks.


Hi webtubbs, sorry just one lat thing how do you show a tab by name? I have tried

MainForm.TabControl1.SelectedTab = MainForm.TabControl1.Name("Customers")
To set the SelectedTab given a Tab Name of "Customers", you would use this....

    Me.TabControl1.SelectedTab = Me.TabControl1.TabPages("Customer")


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial