A simple way to hide tabs on a tab control

If I use the following code it will hide the tab or display the tab, the only problem is that when it displays the tab no control are present inside the tab. Do the controls need to be added dynamically after the Tabpages.add ? or am I missing something?

 If _masterGlobalParameters.masterGlobal.MasterShowDSG_SGProbeTab = True Then
                TabControl1.TabPages.Add(TabSGGages)
            Else
                TabControl1.TabPages.Remove(TabSGGages)
            End If

Open in new window

cmdolcetAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieVBA ExpertCommented:
That code isn't hiding/displaying tabs it's removing/adding them and when you add a tab it will be empty, i.e. have no controls.
0
cmdolcetAuthor Commented:
Its been a long night sorry, however is there a property to actually hide or display a certain tab control?
0
NorieVBA ExpertCommented:
Actually I'm not quite right, when you remove  a tab page it isn't destroyed and you can add it back to the tab control again.

For example if you had 2 tabs you could use this to toggle the second tab.
   Dim tb As TabControl

        tb = TabControl1

        If tb.TabPages.Count = 2 Then

            tb.TabPages.Remove(TabPage2)
        Else
            tb.TabPages.Add(TabPage2)
        End If

Open in new window

Note in this code you have to specify the tab page to add/remove, you can't use an index to refer to the tab page, not sure if that'll affect what you are trying to do but it might be a problem.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

cmdolcetAuthor Commented:
Norie the. count is not a property of the tab control
0
NorieVBA ExpertCommented:
It's a property of the TabPages collection of the tab control, that's why I used TabPages.Count in the code I posted.
0
it_saigeDeveloperCommented:
*NO POINTS*

Norie is correct, you would simply add and remove the tabpage from the tabpages collection.

Create a Component called ComboBoxEx -
ComboBoxEx.vb -
Public Class ComboBoxEx

End Class

Open in new window

ComboBoxEx.Designer.vb -
Imports System.Text

Partial Class ComboBoxEx
    Inherits System.Windows.Forms.ComboBox

    Private _dropDown As Dropdown
    'Required by the Component Designer
    Private components As System.ComponentModel.IContainer
    Private _itemCheck As List(Of ItemCheckEventHandler) = New List(Of ItemCheckEventHandler)
    Public Custom Event ItemCheck As ItemCheckEventHandler
        AddHandler(value As ItemCheckEventHandler)
            _itemCheck.Add(value)
        End AddHandler
        RemoveHandler(value As ItemCheckEventHandler)
            _itemCheck.Remove(value)
        End RemoveHandler
        RaiseEvent(sender As Object, e As ItemCheckEventArgs)
            For Each handler As ItemCheckEventHandler In _itemCheck
                Try
                    handler.Invoke(sender, e)
                Catch ex As Exception

                End Try
            Next
        End RaiseEvent
    End Event

    Public Property ValueSeparator() As String

    Public Property CheckOnClick() As Boolean
        Get
            Return _dropDown.List.CheckOnClick
        End Get
        Set(value As Boolean)
            _dropDown.List.CheckOnClick = value
        End Set
    End Property

    Public Shadows Property DisplayMember() As String
        Get
            Return _dropDown.List.DisplayMember
        End Get
        Set(value As String)
            _dropDown.List.DisplayMember = value
        End Set
    End Property

    Public Shadows ReadOnly Property Items() As CheckedListBox.ObjectCollection
        Get
            Return _dropDown.List.Items
        End Get
    End Property

    Public ReadOnly Property CheckItems() As CheckedListBox.CheckedItemCollection
        Get
            Return _dropDown.List.CheckedItems
        End Get
    End Property

    Public ReadOnly Property CheckedIndicies() As CheckedListBox.CheckedIndexCollection
        Get
            Return _dropDown.List.CheckedIndices
        End Get
    End Property

    Public ReadOnly Property ValueChanged() As Boolean
        Get
            Return _dropDown.ValueChanged
        End Get
    End Property

    Protected Overrides Sub OnDropDown(e As EventArgs)
        If Not _dropDown.Visible Then
            Dim rect As Rectangle = RectangleToScreen(ClientRectangle)
            _dropDown.Location = New System.Drawing.Point(rect.X, rect.Y + Size.Height)
            Dim count = _dropDown.List.Items.Count
            If count > MaxDropDownItems Then
                count = MaxDropDownItems
            ElseIf count = 0 Then
                count = 1
            End If
            _dropDown.Size = New Size(Size.Width, (_dropDown.List.ItemHeight) * count + 2)
            _dropDown.Show(Me)
        End If
    End Sub

    Protected Overrides Sub OnDropDownClosed(e As EventArgs)
        If TypeOf e Is Dropdown.ComboBoxExEventArgs Then
            MyBase.OnDropDownClosed(e)
        End If
    End Sub

    Protected Overrides Sub OnKeyDown(e As KeyEventArgs)
        If e.KeyCode = Keys.Down Then
            OnDropDown(Nothing)
        End If
        e.Handled = Not e.Alt AndAlso Not e.KeyCode = Keys.Tab AndAlso Not (e.KeyCode = Keys.Left OrElse e.KeyCode = Keys.Right OrElse e.KeyCode = Keys.Home OrElse e.KeyCode = Keys.End)
        MyBase.OnKeyDown(e)
    End Sub

    Protected Overrides Sub OnKeyPress(e As KeyPressEventArgs)
        e.Handled = True
        MyBase.OnKeyPress(e)
    End Sub

    Public Function GetItemChecked(index As Integer) As Boolean
        If index < 0 OrElse index > Items.Count Then
            Throw New ArgumentOutOfRangeException("index", "value out of range")
        Else
            Return _dropDown.List.GetItemChecked(index)
        End If
    End Function

    Public Sub SetItemChecked(index As Integer, isChecked As Boolean)
        If index < 0 OrElse index > Items.Count Then
            Throw New ArgumentOutOfRangeException("index", "value out of range")
        Else
            _dropDown.List.SetItemChecked(index, isChecked)
            Text = _dropDown.GetCheckItemsStringValue()
        End If
    End Sub

    Public Function GetItemCheckState(index As Integer) As Boolean
        If index < 0 OrElse index > Items.Count Then
            Throw New ArgumentOutOfRangeException("index", "value out of range")
        Else
            Return _dropDown.List.GetItemCheckState(index)
        End If
    End Function

    Public Sub SetItemCheckState(index As Integer, state As CheckState)
        If index < 0 OrElse index > Items.Count Then
            Throw New ArgumentOutOfRangeException("index", "value out of range")
        Else
            _dropDown.List.SetItemCheckState(index, state)
            Text = _dropDown.GetCheckItemsStringValue()
        End If
    End Sub

    Protected Sub OnItemCheck(sender As Object, e As ItemCheckEventArgs)
        RaiseEvent ItemCheck(sender, e)
    End Sub

    Friend Shadows Class Dropdown
        Inherits System.Windows.Forms.Form

        Private _parent As ComboBoxEx
        Private _oldStringValue As String = ""
        Private _checkedStateArray As List(Of Boolean)
        Private _dropDownClosed As Boolean = True

        Public ReadOnly Property ValueChanged() As Boolean
            Get
                Dim _newStringValue = _parent.Text
                If _oldStringValue.Length > 0 AndAlso _newStringValue.Length > 0 Then
                    Return _oldStringValue.CompareTo(_newStringValue) <> 0
                Else
                    Return _oldStringValue.Length <> _newStringValue.Length
                End If
            End Get
        End Property

        Public Property List() As CheckedListBoxEx

        Public Sub New(parent As ComboBoxEx)
            _parent = parent
            InitializeComponent()
            ShowInTaskbar = False
        End Sub

        Private Sub InitializeComponent()
            List = New CheckedListBoxEx()
            SuspendLayout()
            ''
            '' List
            ''
            List.BorderStyle = System.Windows.Forms.BorderStyle.None
            List.Dock = System.Windows.Forms.DockStyle.Fill
            List.FormattingEnabled = True
            List.Location = New System.Drawing.Point(0, 0)
            List.Name = "List"
            List.Size = New System.Drawing.Size(47, 15)
            List.TabIndex = 0
            ''
            '' Dropdown
            ''
            AutoScaleDimensions = New System.Drawing.SizeF(6.0F, 13.0F)
            AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            BackColor = System.Drawing.SystemColors.Menu
            ClientSize = New System.Drawing.Size(47, 16)
            ControlBox = False
            Controls.Add(List)
            ForeColor = System.Drawing.SystemColors.ControlText
            FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
            MinimizeBox = False
            Name = "_parent"
            StartPosition = System.Windows.Forms.FormStartPosition.Manual
            ResumeLayout()
        End Sub

        Public Function GetCheckItemsStringValue() As String
            Return String.Join(_parent.ValueSeparator, (From item In List.CheckedItems Select List.GetItemText(item)))
        End Function

        Public Sub CloseDropDown(enactChanges As Boolean)
            If _dropDownClosed Then Return
            Debug.WriteLine("CloseDropDown")
            If enactChanges Then
                _parent.SelectedIndex = -1
                _parent.Text = GetCheckItemsStringValue()
            Else
                For i As Integer = 0 To List.Items.Count - 1
                    List.SetItemChecked(i, _checkedStateArray(i))
                Next
            End If
            _dropDownClosed = True
            _parent.Focus()
            Hide()
            _parent.OnDropDownClosed(New ComboBoxExEventArgs(Nothing, False))
        End Sub

        Protected Overrides Sub OnActivated(e As EventArgs)
            Debug.WriteLine("OnActivated")
            MyBase.OnActivated(e)
            _dropDownClosed = False
            _oldStringValue = _parent.Text
            _checkedStateArray = New List(Of Boolean)(List.Items.Count)
            If List.Items.Count <> 0 Then
                For i As Integer = 0 To List.Items.Count - 1
                    _checkedStateArray.Add(List.GetItemChecked(i))
                Next
            End If
        End Sub

        Protected Overrides Sub OnDeactivate(e As EventArgs)
            Debug.WriteLine("OnDeactivate")
            MyBase.OnDeactivate(e)
            If TypeOf e Is ComboBoxExEventArgs Then
                CloseDropDown(CType(e, ComboBoxExEventArgs).AssignValues)
            Else
                CloseDropDown(True)
            End If
        End Sub

        Friend Class ComboBoxExEventArgs
            Inherits EventArgs

            Public Property AssignValues() As Boolean
            Public Property EventArgs() As EventArgs

            Public Sub New(e As EventArgs, assignValues As Boolean)
                Me.EventArgs = e
                Me.AssignValues = assignValues
            End Sub
        End Class

        Friend Class CheckedListBoxEx
            Inherits System.Windows.Forms.CheckedListBox

            Private _selectedIndex As Integer = -1

            Public Sub New()
                Me.SelectionMode = SelectionMode.One
                Me.HorizontalScrollbar = True
            End Sub

            Protected Overrides Sub OnKeyDown(e As KeyEventArgs)
                If e.KeyCode = Keys.Enter Then
                    CType(Parent, ComboBoxEx.Dropdown).OnDeactivate(New ComboBoxExEventArgs(Nothing, True))
                    e.Handled = True
                ElseIf e.KeyCode = Keys.Escape Then
                    CType(Parent, ComboBoxEx.Dropdown).OnDeactivate(New ComboBoxExEventArgs(Nothing, False))
                    e.Handled = True
                ElseIf e.KeyCode = Keys.Delete Then
                    For i As Integer = 0 To Items.Count - 1
                        SetItemChecked(i, e.Shift)
                    Next
                    e.Handled = True
                End If
                MyBase.OnKeyDown(e)
            End Sub

            Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
                MyBase.OnMouseMove(e)
                Dim index As Integer = IndexFromPoint(e.Location)
                Debug.WriteLine($"Mouse over item: {If(index >= 0, GetItemText(Items(index)), "None")}")
                If index >= 0 AndAlso index <> _selectedIndex Then
                    _selectedIndex = index
                    SetSelected(index, True)
                End If
            End Sub
        End Class
    End Class

    <System.Diagnostics.DebuggerNonUserCode()>
    Public Sub New()
        MyBase.New()
        'This call is required by the Component Designer.
        InitializeComponent()

        DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable
        ValueSeparator = ", "
        DropDownHeight = 1
        DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown
        _dropDown = New Dropdown(Me)
        AddHandler _dropDown.List.ItemCheck, AddressOf OnItemCheck
        CheckOnClick = True
    End Sub

    'Component overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()>
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub


    'NOTE: The following procedure is required by the Component Designer
    'It can be modified using the Component Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()>
    Private Sub InitializeComponent()
        components = New System.ComponentModel.Container()
    End Sub
End Class

Open in new window


Form1.vb -
Imports System.Runtime.CompilerServices

Public Class Form1
    Private Sub OnLoad(sender As Object, e As EventArgs) Handles MyBase.Load
        For Each page In Controls.GetChildren(GetType(TabPage))
            ComboBox1.Items.Add(New With {.DisplayMember = page.Name, .ValueMember = page})
        Next
        ComboBox1.ValueMember = "ValueMember"
        ComboBox1.DisplayMember = "DisplayMember"
    End Sub

    Private Sub OnItemCheck(sender As Object, e As ItemCheckEventArgs) Handles ComboBox1.ItemCheck
        If TypeOf sender Is ComboBoxEx.Dropdown.CheckedListBoxEx Then
            Dim item = CType(sender, ComboBoxEx.Dropdown.CheckedListBoxEx).Items(e.Index)
            Dim page = If(item IsNot Nothing AndAlso item.ValueMember IsNot Nothing AndAlso TypeOf item.ValueMember Is TabPage, CType(item.ValueMember, TabPage), Nothing)
            If page IsNot Nothing Then
                If CBool(e.NewValue) Then
                    TabControl1.HidePage(page)
                Else
                    TabControl1.ShowPage(page, e.Index)
                End If
            End If
        End If
    End Sub
End Class

Module Extensions
    <Extension>
    Public Function GetChildren(source As Control.ControlCollection, Optional ByVal filter As Type = Nothing) As IEnumerable(Of Control)
        Dim children As List(Of Control) = New List(Of Control)
        For Each child As Control In source
            If child.GetType() Is If(filter IsNot Nothing, filter, GetType(Control)) Then children.Add(child)
            If child.HasChildren() Then children.AddRange(child.Controls.GetChildren(filter))
        Next
        Return children
    End Function

    <Extension>
    Public Sub HidePage(parent As TabControl, page As TabPage)
        If parent IsNot Nothing AndAlso page IsNot Nothing Then
            parent.TabPages.Remove(page)
        End If
    End Sub

    <Extension>
    Public Sub ShowPage(parent As TabControl, page As TabPage, index As Integer)
        If parent IsNot Nothing AndAlso page IsNot Nothing Then
            If index < parent.TabPages.Count Then
                parent.TabPages.Insert(index, page)
            Else
                parent.TabPages.Add(page)
            End If
        End If
    End Sub
End Module

Open in new window


Form1.Designer.vb -
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.ComboBox1 = New EE_Q29073200.ComboBoxEx()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.TabControl1 = New System.Windows.Forms.TabControl()
        Me.TabPage1 = New System.Windows.Forms.TabPage()
        Me.TabPage2 = New System.Windows.Forms.TabPage()
        Me.TabPage3 = New System.Windows.Forms.TabPage()
        Me.TabPage4 = New System.Windows.Forms.TabPage()
        Me.TabPage5 = New System.Windows.Forms.TabPage()
        Me.TabPage6 = New System.Windows.Forms.TabPage()
        Me.TabPage7 = New System.Windows.Forms.TabPage()
        Me.TabPage8 = New System.Windows.Forms.TabPage()
        Me.TabPage9 = New System.Windows.Forms.TabPage()
        Me.TabPage10 = New System.Windows.Forms.TabPage()
        Me.TabControl1.SuspendLayout()
        Me.SuspendLayout()
        '
        'ComboBox1
        '
        Me.ComboBox1.CheckOnClick = True
        Me.ComboBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable
        Me.ComboBox1.DropDownHeight = 1
        Me.ComboBox1.FormattingEnabled = True
        Me.ComboBox1.IntegralHeight = False
        Me.ComboBox1.Location = New System.Drawing.Point(532, 13)
        Me.ComboBox1.Name = "ComboBox1"
        Me.ComboBox1.Size = New System.Drawing.Size(190, 21)
        Me.ComboBox1.TabIndex = 0
        Me.ComboBox1.ValueSeparator = ", "
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(484, 17)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(42, 13)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "Panels:"
        '
        'TabControl1
        '
        Me.TabControl1.Controls.Add(Me.TabPage1)
        Me.TabControl1.Controls.Add(Me.TabPage2)
        Me.TabControl1.Controls.Add(Me.TabPage3)
        Me.TabControl1.Controls.Add(Me.TabPage4)
        Me.TabControl1.Controls.Add(Me.TabPage5)
        Me.TabControl1.Controls.Add(Me.TabPage6)
        Me.TabControl1.Controls.Add(Me.TabPage7)
        Me.TabControl1.Controls.Add(Me.TabPage8)
        Me.TabControl1.Controls.Add(Me.TabPage9)
        Me.TabControl1.Controls.Add(Me.TabPage10)
        Me.TabControl1.Location = New System.Drawing.Point(12, 40)
        Me.TabControl1.Name = "TabControl1"
        Me.TabControl1.SelectedIndex = 0
        Me.TabControl1.Size = New System.Drawing.Size(710, 318)
        Me.TabControl1.TabIndex = 2
        '
        'TabPage1
        '
        Me.TabPage1.Location = New System.Drawing.Point(4, 22)
        Me.TabPage1.Name = "TabPage1"
        Me.TabPage1.Padding = New System.Windows.Forms.Padding(3)
        Me.TabPage1.Size = New System.Drawing.Size(702, 292)
        Me.TabPage1.TabIndex = 0
        Me.TabPage1.Text = "TabPage1"
        Me.TabPage1.UseVisualStyleBackColor = True
        '
        'TabPage2
        '
        Me.TabPage2.Location = New System.Drawing.Point(4, 22)
        Me.TabPage2.Name = "TabPage2"
        Me.TabPage2.Padding = New System.Windows.Forms.Padding(3)
        Me.TabPage2.Size = New System.Drawing.Size(702, 292)
        Me.TabPage2.TabIndex = 1
        Me.TabPage2.Text = "TabPage2"
        Me.TabPage2.UseVisualStyleBackColor = True
        '
        'TabPage3
        '
        Me.TabPage3.Location = New System.Drawing.Point(4, 22)
        Me.TabPage3.Name = "TabPage3"
        Me.TabPage3.Padding = New System.Windows.Forms.Padding(3)
        Me.TabPage3.Size = New System.Drawing.Size(702, 292)
        Me.TabPage3.TabIndex = 2
        Me.TabPage3.Text = "TabPage3"
        Me.TabPage3.UseVisualStyleBackColor = True
        '
        'TabPage4
        '
        Me.TabPage4.Location = New System.Drawing.Point(4, 22)
        Me.TabPage4.Name = "TabPage4"
        Me.TabPage4.Padding = New System.Windows.Forms.Padding(3)
        Me.TabPage4.Size = New System.Drawing.Size(702, 292)
        Me.TabPage4.TabIndex = 3
        Me.TabPage4.Text = "TabPage4"
        Me.TabPage4.UseVisualStyleBackColor = True
        '
        'TabPage5
        '
        Me.TabPage5.Location = New System.Drawing.Point(4, 22)
        Me.TabPage5.Name = "TabPage5"
        Me.TabPage5.Padding = New System.Windows.Forms.Padding(3)
        Me.TabPage5.Size = New System.Drawing.Size(702, 292)
        Me.TabPage5.TabIndex = 4
        Me.TabPage5.Text = "TabPage5"
        Me.TabPage5.UseVisualStyleBackColor = True
        '
        'TabPage6
        '
        Me.TabPage6.Location = New System.Drawing.Point(4, 22)
        Me.TabPage6.Name = "TabPage6"
        Me.TabPage6.Padding = New System.Windows.Forms.Padding(3)
        Me.TabPage6.Size = New System.Drawing.Size(702, 292)
        Me.TabPage6.TabIndex = 5
        Me.TabPage6.Text = "TabPage6"
        Me.TabPage6.UseVisualStyleBackColor = True
        '
        'TabPage7
        '
        Me.TabPage7.Location = New System.Drawing.Point(4, 22)
        Me.TabPage7.Name = "TabPage7"
        Me.TabPage7.Padding = New System.Windows.Forms.Padding(3)
        Me.TabPage7.Size = New System.Drawing.Size(702, 292)
        Me.TabPage7.TabIndex = 6
        Me.TabPage7.Text = "TabPage7"
        Me.TabPage7.UseVisualStyleBackColor = True
        '
        'TabPage8
        '
        Me.TabPage8.Location = New System.Drawing.Point(4, 22)
        Me.TabPage8.Name = "TabPage8"
        Me.TabPage8.Padding = New System.Windows.Forms.Padding(3)
        Me.TabPage8.Size = New System.Drawing.Size(702, 292)
        Me.TabPage8.TabIndex = 7
        Me.TabPage8.Text = "TabPage8"
        Me.TabPage8.UseVisualStyleBackColor = True
        '
        'TabPage9
        '
        Me.TabPage9.Location = New System.Drawing.Point(4, 22)
        Me.TabPage9.Name = "TabPage9"
        Me.TabPage9.Padding = New System.Windows.Forms.Padding(3)
        Me.TabPage9.Size = New System.Drawing.Size(702, 292)
        Me.TabPage9.TabIndex = 8
        Me.TabPage9.Text = "TabPage9"
        Me.TabPage9.UseVisualStyleBackColor = True
        '
        'TabPage10
        '
        Me.TabPage10.Location = New System.Drawing.Point(4, 22)
        Me.TabPage10.Name = "TabPage10"
        Me.TabPage10.Padding = New System.Windows.Forms.Padding(3)
        Me.TabPage10.Size = New System.Drawing.Size(702, 292)
        Me.TabPage10.TabIndex = 9
        Me.TabPage10.Text = "TabPage10"
        Me.TabPage10.UseVisualStyleBackColor = True
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(734, 370)
        Me.Controls.Add(Me.TabControl1)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.ComboBox1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.TabControl1.ResumeLayout(False)
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

    Friend WithEvents ComboBox1 As ComboBoxEx
    Friend WithEvents Label1 As Label
    Friend WithEvents TabControl1 As TabControl
    Friend WithEvents TabPage1 As TabPage
    Friend WithEvents TabPage2 As TabPage
    Friend WithEvents TabPage3 As TabPage
    Friend WithEvents TabPage4 As TabPage
    Friend WithEvents TabPage5 As TabPage
    Friend WithEvents TabPage6 As TabPage
    Friend WithEvents TabPage7 As TabPage
    Friend WithEvents TabPage8 As TabPage
    Friend WithEvents TabPage9 As TabPage
    Friend WithEvents TabPage10 As TabPage
End Class

Open in new window


Produces the following output -
Initial Load -Capture.PNGAdding and removing tabs happens as you select and deselect the checkboxes in the panel drop-down:Capture.PNG
-saige-
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.