Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-02-21
3
Medium Priority
?
1,640 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:Murray Brown
[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 2000 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:Murray Brown
ID: 39878899
thanks very much
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

604 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