Solved

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

Posted on 2014-02-21
3
1,283 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
  • 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now