Solved

VB.net Tab Control - allow user to add, delete and name tabs

Posted on 2014-02-21
3
1,454 Views
Last Modified: 2014-02-22
Hi
I have a tab control that I want users to add, delete and name tabs
What is the best way to do this?
0
Comment
Question by:murbro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 40
ID: 39877597
Creating the tabs is not a big problem, it looks something like the following.<

            Dim newTab As New TabPage("Tab Text")
            TabControl1.TabPages.Add(newTab)

The problem is that you end up with an empty TabPage with no controls on it.

I suppose that you want to repeat the same thing on each tab. In such a case, a UserControl or a Form (a form is a Control and can be used in a TabPage) could be designed to provide the controls that needs to be shown in the page. A UserControl requires less resources, but does have all the events that a Form has, so sometimes a Form would be a better choice. I would try with a UserControl first. The remaining of this discussion is the same for both.

To simplify things, this UserControl should contain all the necessary functionality for the data in the page. For instance, if the user needs to be able to Save the data, it is a lot easier to do from a Button in the UserControl than from a menu in the main Form.

To add your UserControl to the new TabPage, we will extend the previous code this way:

            Dim newTab As New TabPage("Tab Text")

            newTab.Controls.Add(New UserControl1)
            TabControl1.TabPages.Add(newTab)
            TabControl1.SelectedTab = newTab
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 39877607
Oops. Forgot the Rename and Delete:

            TabControl1.SelectedTab.Text = "New Text"
            TabControl1.TabPages.Remove(TabControl1.SelectedTab)
0
 

Author Closing Comment

by:murbro
ID: 39878899
thanks very much
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question