Solved

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

Posted on 2014-02-21
3
1,495 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 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:Murray Brown
ID: 39878899
thanks very much
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 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