Solved

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

735 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