VB.Net Tutorial/GUI/TabControl — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 16:40, 26 мая 2010

Add new Tab

Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class AddNewTab
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class
Public Class Form1
    Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
    Public Sub New()
        MyBase.New()
        "This call is required by the Windows Form Designer.
        InitializeComponent()
        "Add any initialization after the InitializeComponent() call
    End Sub
    "Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    "Required by the Windows Form Designer
    Private components As System.ruponentModel.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.
    Friend WithEvents TabControl1 As System.Windows.Forms.TabControl
    Friend WithEvents TabPage1 As System.Windows.Forms.TabPage
    Friend WithEvents TabPage2 As System.Windows.Forms.TabPage
    Friend WithEvents TabPage3 As System.Windows.Forms.TabPage
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Button1 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        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.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.Button1 = New System.Windows.Forms.Button
        Me.TabControl1.SuspendLayout()
        Me.TabPage1.SuspendLayout()
        Me.TabPage2.SuspendLayout()
        Me.TabPage3.SuspendLayout()
        Me.SuspendLayout()
        "
        "TabControl1
        "
        Me.TabControl1.Controls.Add(Me.TabPage1)
        Me.TabControl1.Controls.Add(Me.TabPage2)
        Me.TabControl1.Controls.Add(Me.TabPage3)
        Me.TabControl1.Dock = System.Windows.Forms.DockStyle.Bottom
        Me.TabControl1.HotTrack = True
        Me.TabControl1.Location = New System.Drawing.Point(0, 89)
        Me.TabControl1.Name = "TabControl1"
        Me.TabControl1.SelectedIndex = 0
        Me.TabControl1.Size = New System.Drawing.Size(292, 184)
        Me.TabControl1.TabIndex = 1
        "
        "TabPage1
        "
        Me.TabPage1.Controls.Add(Me.Label2)
        Me.TabPage1.Location = New System.Drawing.Point(4, 22)
        Me.TabPage1.Name = "TabPage1"
        Me.TabPage1.Size = New System.Drawing.Size(284, 158)
        Me.TabPage1.TabIndex = 0
        Me.TabPage1.Text = "Tab Page 1"
        "
        "TabPage2
        "
        Me.TabPage2.Controls.Add(Me.Label3)
        Me.TabPage2.Location = New System.Drawing.Point(4, 22)
        Me.TabPage2.Name = "TabPage2"
        Me.TabPage2.Size = New System.Drawing.Size(284, 158)
        Me.TabPage2.TabIndex = 1
        Me.TabPage2.Text = "Tab Page 2"
        "
        "TabPage3
        "
        Me.TabPage3.Controls.Add(Me.Label4)
        Me.TabPage3.Location = New System.Drawing.Point(4, 22)
        Me.TabPage3.Name = "TabPage3"
        Me.TabPage3.Size = New System.Drawing.Size(284, 158)
        Me.TabPage3.TabIndex = 2
        Me.TabPage3.Text = "Tab Page 3"
        "
        "Label2
        "
        Me.Label2.Dock = System.Windows.Forms.DockStyle.Fill
        Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 24.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label2.Location = New System.Drawing.Point(0, 0)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(284, 158)
        Me.Label2.TabIndex = 0
        Me.Label2.Text = "Tab Page 1"
        "
        "Label3
        "
        Me.Label3.Dock = System.Windows.Forms.DockStyle.Fill
        Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 24.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label3.Location = New System.Drawing.Point(0, 0)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(284, 158)
        Me.Label3.TabIndex = 0
        Me.Label3.Text = "Tab Page 2"
        "
        "Label4
        "
        Me.Label4.Dock = System.Windows.Forms.DockStyle.Fill
        Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 24.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label4.Location = New System.Drawing.Point(0, 0)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(284, 158)
        Me.Label4.TabIndex = 0
        Me.Label4.Text = "Tab Page 3"
        "
        "Button1
        "
        Me.Button1.Location = New System.Drawing.Point(96, 48)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(88, 23)
        Me.Button1.TabIndex = 2
        Me.Button1.Text = "Add New Tab"
        "
        "Form1
        "
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.TabControl1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.TabControl1.ResumeLayout(False)
        Me.TabPage1.ResumeLayout(False)
        Me.TabPage2.ResumeLayout(False)
        Me.TabPage3.ResumeLayout(False)
        Me.ResumeLayout(False)
    End Sub
#End Region
    Dim tabPage4 As New TabPage
    Dim lblLabel1 As New Label
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        tabPage4.Text = "Tab Page 4"
        TabControl1.TabPages.Add(tabPage4)
        lblLabel1.Dock = DockStyle.Fill
        lblLabel1.Text = "Tab Page 4"
        lblLabel1.Font = New Font("Microsoft San Serif", 24)
        TabControl1.TabPages(3).Controls.Add(lblLabel1)
    End Sub
End Class

Custom Tab

Imports System.Windows.Forms
Imports System.Drawing
public class CustomTabControl
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class
Public Class Form1
    " Draw ellipses in the tabs.
    Private Sub tabProject_DrawItem(ByVal sender As Object, _
     ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles tabProject.DrawItem
        " Get the drawing bounds.
        Dim rect As Rectangle = e.Bounds
        If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
            " Allow extra room for the selected tab.
            rect.X += 4
            rect.Y += 4
            rect.Width -= 8
            rect.Height -= 8
        Else
            rect.X += 2
            rect.Y += 2
            rect.Width -= 4
            rect.Height -= 4
        End If
        " Fill the ellipse with the right color.
        Select Case e.Index
            Case 0
                e.Graphics.FillEllipse(Brushes.Green, rect)
            Case 1
                e.Graphics.FillEllipse(Brushes.Yellow, rect)
            Case 2
                e.Graphics.FillEllipse(Brushes.Red, rect)
        End Select
        " Outline the ellipse in black.
        If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
            " Use a thick line for the selected tab.
            e.Graphics.DrawEllipse( _
                New Pen(Color.Black, 3), _
                rect)
        Else
            e.Graphics.DrawEllipse(Pens.Black, rect)
        End If
    End Sub
End Class
<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _
Partial Public Class Form1
    Inherits System.Windows.Forms.Form
    "Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub
    "Required by the Windows Form Designer
    Private components As System.ruponentModel.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.tabProject = 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.tabProject.SuspendLayout()
        Me.SuspendLayout()
        "
        "tabProject
        "
        Me.tabProject.Controls.Add(Me.TabPage1)
        Me.tabProject.Controls.Add(Me.TabPage2)
        Me.tabProject.Controls.Add(Me.TabPage3)
        Me.tabProject.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed
        Me.tabProject.Location = New System.Drawing.Point(8, 8)
        Me.tabProject.Name = "tabProject"
        Me.tabProject.SelectedIndex = 0
        Me.tabProject.Size = New System.Drawing.Size(272, 200)
        Me.tabProject.TabIndex = 1
        "
        "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(264, 174)
        Me.TabPage1.TabIndex = 0
        Me.TabPage1.Text = "TabPage1"
        "
        "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(264, 174)
        Me.TabPage2.TabIndex = 1
        Me.TabPage2.Text = "TabPage2"
        "
        "TabPage3
        "
        Me.TabPage3.Location = New System.Drawing.Point(4, 22)
        Me.TabPage3.Name = "TabPage3"
        Me.TabPage3.Size = New System.Drawing.Size(264, 174)
        Me.TabPage3.TabIndex = 2
        Me.TabPage3.Text = "TabPage3"
        "
        "Form1
        "
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(289, 217)
        Me.Controls.Add(Me.tabProject)
        Me.Name = "Form1"
        Me.Text = "UseTabControlOwnerDrawn"
        Me.tabProject.ResumeLayout(False)
        Me.ResumeLayout(False)
    End Sub
    Friend WithEvents tabProject As System.Windows.Forms.TabControl
    Friend WithEvents TabPage1 As System.Windows.Forms.TabPage
    Friend WithEvents TabPage2 As System.Windows.Forms.TabPage
    Friend WithEvents TabPage3 As System.Windows.Forms.TabPage
End Class

Put RadioButtons to a Tab Control

Imports System.Windows.Forms
public class TabControlRadioButton
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If RadioButton1.Checked = True Then
            Me.BackColor = System.Drawing.Color.Red
        End If
        If RadioButton2.Checked = True Then
            Me.BackColor = System.Drawing.Color.Blue
        End If
    End Sub
End Class
<Global.Microsoft.VisualBasic.rupilerServices.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)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub
    "Required by the Windows Form Designer
    Private components As System.ruponentModel.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.TabControl1 = New System.Windows.Forms.TabControl
        Me.myscreensave = New System.Windows.Forms.TabPage
        Me.mybackground = New System.Windows.Forms.TabPage
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.RadioButton1 = New System.Windows.Forms.RadioButton
        Me.RadioButton2 = New System.Windows.Forms.RadioButton
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.TabControl1.SuspendLayout()
        Me.myscreensave.SuspendLayout()
        Me.mybackground.SuspendLayout()
        Me.SuspendLayout()
        "
        "TabControl1
        "
        Me.TabControl1.Controls.Add(Me.myscreensave)
        Me.TabControl1.Controls.Add(Me.mybackground)
        Me.TabControl1.Location = New System.Drawing.Point(17, 12)
        Me.TabControl1.Name = "TabControl1"
        Me.TabControl1.SelectedIndex = 0
        Me.TabControl1.Size = New System.Drawing.Size(379, 161)
        Me.TabControl1.TabIndex = 0
        "
        "myscreensave
        "
        Me.myscreensave.Controls.Add(Me.TextBox1)
        Me.myscreensave.Location = New System.Drawing.Point(4, 21)
        Me.myscreensave.Name = "myscreensave"
        Me.myscreensave.Padding = New System.Windows.Forms.Padding(3)
        Me.myscreensave.Size = New System.Drawing.Size(371, 136)
        Me.myscreensave.TabIndex = 0
        Me.myscreensave.Text = "Screen Saver"
        Me.myscreensave.UseVisualStyleBackColor = True
        "
        "mybackground
        "
        Me.mybackground.Controls.Add(Me.RadioButton2)
        Me.mybackground.Controls.Add(Me.RadioButton1)
        Me.mybackground.Controls.Add(Me.Label1)
        Me.mybackground.Location = New System.Drawing.Point(4, 21)
        Me.mybackground.Name = "mybackground"
        Me.mybackground.Padding = New System.Windows.Forms.Padding(3)
        Me.mybackground.Size = New System.Drawing.Size(371, 156)
        Me.mybackground.TabIndex = 1
        Me.mybackground.Text = "Color"
        Me.mybackground.UseVisualStyleBackColor = True
        "
        "TextBox1
        "
        Me.TextBox1.Location = New System.Drawing.Point(6, 101)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(260, 21)
        Me.TextBox1.TabIndex = 0
        Me.TextBox1.Text = "Function"
        "
        "Label1
        "
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(23, 16)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(89, 12)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Select"
        "
        "RadioButton1
        "
        Me.RadioButton1.AutoSize = True
        Me.RadioButton1.Location = New System.Drawing.Point(25, 49)
        Me.RadioButton1.Name = "RadioButton1"
        Me.RadioButton1.Size = New System.Drawing.Size(47, 16)
        Me.RadioButton1.TabIndex = 1
        Me.RadioButton1.TabStop = True
        Me.RadioButton1.Text = "Red"
        Me.RadioButton1.UseVisualStyleBackColor = True
        "
        "RadioButton2
        "
        Me.RadioButton2.AutoSize = True
        Me.RadioButton2.Location = New System.Drawing.Point(25, 71)
        Me.RadioButton2.Name = "RadioButton2"
        Me.RadioButton2.Size = New System.Drawing.Size(47, 16)
        Me.RadioButton2.TabIndex = 2
        Me.RadioButton2.TabStop = True
        Me.RadioButton2.Text = "Blue"
        Me.RadioButton2.UseVisualStyleBackColor = True
        "
        "Button1
        "
        Me.Button1.Location = New System.Drawing.Point(58, 179)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(75, 23)
        Me.Button1.TabIndex = 1
        Me.Button1.Text = "OK"
        Me.Button1.UseVisualStyleBackColor = True
        "
        "Button2
        "
        Me.Button2.Location = New System.Drawing.Point(250, 179)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(75, 23)
        Me.Button2.TabIndex = 2
        Me.Button2.Text = "Cancel"
        Me.Button2.UseVisualStyleBackColor = True
        "
        "Form1
        "
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(407, 214)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.TabControl1)
        Me.Name = "Form1"
        Me.Text = "TabControl Demo"
        Me.TabControl1.ResumeLayout(False)
        Me.myscreensave.ResumeLayout(False)
        Me.myscreensave.PerformLayout()
        Me.mybackground.ResumeLayout(False)
        Me.mybackground.PerformLayout()
        Me.ResumeLayout(False)
    End Sub
    Friend WithEvents TabControl1 As System.Windows.Forms.TabControl
    Friend WithEvents myscreensave As System.Windows.Forms.TabPage
    Friend WithEvents mybackground As System.Windows.Forms.TabPage
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
    Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
End Class

Tab Control

Imports System.Windows.Forms
public class TabControl
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class
Public Class Form1
    Inherits System.Windows.Forms.Form
    Public Sub New()
        MyBase.New()
        InitializeComponent()
    End Sub
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Private components As System.ruponentModel.IContainer
    Friend WithEvents TabControl1 As System.Windows.Forms.TabControl
    Friend WithEvents TabPage1 As System.Windows.Forms.TabPage
    Friend WithEvents TabPage2 As System.Windows.Forms.TabPage
    Friend WithEvents TabPage3 As System.Windows.Forms.TabPage
    Friend WithEvents TabPage4 As System.Windows.Forms.TabPage
    Friend WithEvents TabPage5 As System.Windows.Forms.TabPage
    Friend WithEvents TabPage6 As System.Windows.Forms.TabPage
    Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        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.ListBox1 = New System.Windows.Forms.ListBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.TabControl1.SuspendLayout()
        Me.TabPage1.SuspendLayout()
        Me.SuspendLayout()
        "
        "TabControl1
        "
        Me.TabControl1.Controls.Add(Me.TabPage1)
        Me.TabControl1.Controls.Add(Me.TabPage3)
        Me.TabControl1.Controls.Add(Me.TabPage2)
        Me.TabControl1.Controls.Add(Me.TabPage4)
        Me.TabControl1.Controls.Add(Me.TabPage5)
        Me.TabControl1.Controls.Add(Me.TabPage6)
        Me.TabControl1.Location = New System.Drawing.Point(40, 24)
        Me.TabControl1.Multiline = True
        Me.TabControl1.Name = "TabControl1"
        Me.TabControl1.SelectedIndex = 0
        Me.TabControl1.Size = New System.Drawing.Size(208, 208)
        Me.TabControl1.TabIndex = 0
        "
        "TabPage1
        "
        Me.TabPage1.Controls.Add(Me.Button2)
        Me.TabPage1.Controls.Add(Me.Button1)
        Me.TabPage1.Controls.Add(Me.ListBox1)
        Me.TabPage1.Location = New System.Drawing.Point(4, 40)
        Me.TabPage1.Name = "TabPage1"
        Me.TabPage1.Size = New System.Drawing.Size(200, 164)
        Me.TabPage1.TabIndex = 0
        Me.TabPage1.Text = "A"
        "
        "TabPage2
        "
        Me.TabPage2.Location = New System.Drawing.Point(4, 22)
        Me.TabPage2.Name = "TabPage2"
        Me.TabPage2.Size = New System.Drawing.Size(232, 182)
        Me.TabPage2.TabIndex = 1
        Me.TabPage2.Text = "B"
        "
        "TabPage3
        "
        Me.TabPage3.Location = New System.Drawing.Point(4, 40)
        Me.TabPage3.Name = "TabPage3"
        Me.TabPage3.Size = New System.Drawing.Size(200, 164)
        Me.TabPage3.TabIndex = 2
        Me.TabPage3.Text = "C"
        "
        "TabPage4
        "
        Me.TabPage4.Location = New System.Drawing.Point(4, 40)
        Me.TabPage4.Name = "TabPage4"
        Me.TabPage4.Size = New System.Drawing.Size(232, 164)
        Me.TabPage4.TabIndex = 3
        Me.TabPage4.Text = "D"
        "
        "TabPage5
        "
        Me.TabPage5.Location = New System.Drawing.Point(4, 40)
        Me.TabPage5.Name = "TabPage5"
        Me.TabPage5.Size = New System.Drawing.Size(232, 164)
        Me.TabPage5.TabIndex = 4
        Me.TabPage5.Text = "E"
        "
        "TabPage6
        "
        Me.TabPage6.Location = New System.Drawing.Point(4, 40)
        Me.TabPage6.Name = "TabPage6"
        Me.TabPage6.Size = New System.Drawing.Size(200, 164)
        Me.TabPage6.TabIndex = 5
        Me.TabPage6.Text = "F"
        "
        "ListBox1
        "
        Me.ListBox1.Items.AddRange(New Object() {"A", "B", "C"})
        Me.ListBox1.Location = New System.Drawing.Point(16, 16)
        Me.ListBox1.Name = "ListBox1"
        Me.ListBox1.Size = New System.Drawing.Size(88, 108)
        Me.ListBox1.TabIndex = 0
        "
        "Button1
        "
        Me.Button1.Location = New System.Drawing.Point(120, 32)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(56, 24)
        Me.Button1.TabIndex = 1
        Me.Button1.Text = "Add"
        "
        "Button2
        "
        Me.Button2.Location = New System.Drawing.Point(120, 88)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(56, 24)
        Me.Button2.TabIndex = 2
        Me.Button2.Text = "Delete"
        "
        "Form1
        "
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Controls.Add(Me.TabControl1)
        Me.TabControl1.ResumeLayout(False)
        Me.TabPage1.ResumeLayout(False)
        Me.ResumeLayout(False)
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListBox1.Items.Add("str")
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ListBox1.Items.Remove(ListBox1.SelectedItem)
    End Sub
End Class

TabControl and TabPages

imports System
imports System.Drawing
imports System.Windows.Forms

public class TabControls : inherits Form
  public sub New()
    Size = new Size(325,375)
    dim tc as new TabControl()
    tc.Parent = me
    tc.Size = new Size(275,300)
    tc.Location = new Point(25,25)
    tc.Anchor = AnchorStyles.Top or AnchorStyles.Bottom or AnchorStyles.Left or AnchorStyles.Right
    tc.Alignment = TabAlignment.Top
    tc.Appearance = TabAppearance.Normal
    tc.HotTrack = true
    tc.Multiline = true
    tc.Padding = new Point(20,3)
    tc.SizeMode = TabSizeMode.FillToRight
    AddHandler tc.SelectedIndexChanged, AddressOf tc_Changed
    tc.Text = "Some text"
    dim img as Image = Image.FromFile("1.ico")
    dim imgList as new ImageList()
    imgList.Images.Add(img)
    tc.ImageList = imgList
    dim tpAddress as new TabPage()
    tpAddress.Parent = tc
    tpAddress.Text = "Address Book"
    dim tpDates as new TabPage()
    tpDates.Parent = tc
    tpDates.Text = "Date Book"
    dim tpToDo as new TabPage()
    tpToDo.Parent = tc
    tpToDo.Text = "ToDo List"
    dim tpMisc as new TabPage()
    tpMisc.Parent = tc
    tpMisc.Text = "A Really Long Tab"
    tpMisc.ImageIndex = 0
    dim lbl as new Label()
    lbl.Parent = tpAddress
    lbl.Text = "Put the Address book controls on this page."
    lbl.AutoSize = true
    lbl.Location = new Point(10,25)
    dim pnl as new Panel()
    pnl.Parent = tpDates
    pnl.BorderStyle = BorderStyle.Fixed3D
    pnl.Location = new Point(10,10)
    pnl.Anchor = AnchorStyles.Top or AnchorStyles.Bottom or _
          AnchorStyles.Left or AnchorStyles.Right
    pnl.Size = new Size(tpDates.Width - 20, tpDates.Height - 20)
    dim cal as new MonthCalendar()
    cal.Parent = pnl
    cal.Location = new Point(25,25)
    dim rtxt as new RichTextBox()
    rtxt.Parent = tpToDo
    rtxt.Dock = DockStyle.Fill
    rtxt.BorderStyle = BorderStyle.FixedSingle
  end sub
  public shared sub Main() 
    Application.Run(new TabControls())
  end sub
  private sub tc_Changed(ByVal sender as object,ByVal e as EventArgs)
    dim tc as TabControl = CType(sender,TabControl)
    Console.WriteLine("Button " + tc.SelectedIndex.ToString())
  end sub
end class

Using TabControl to display various font settings

Imports System.Windows.Forms
Imports System.Drawing
Imports System.Drawing.Drawing2D
public class FormTabControl
   public Shared Sub Main
        Application.Run(New FrmTabs)
   End Sub
End class

Public Class FrmTabs
   Inherits Form
#Region " Windows Form Designer generated code "
   Public Sub New()
      MyBase.New()
      "This call is required by the Windows Form Designer.
      InitializeComponent()
      "Add any initialization after the InitializeComponent() call
   End Sub
   "Form overrides dispose to clean up the component list.
   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
      If disposing Then
         If Not (components Is Nothing) Then
            components.Dispose()
         End If
      End If
      MyBase.Dispose(disposing)
   End Sub
   " output label reflects text changes
   Friend WithEvents lblDisplay As Label
   " table control containing table pages tbpColor,
   " tbpSize, tbpMessage and tbpAbout
   Friend WithEvents tbcTextOptions As TabControl
   " table page containing color options
   Friend WithEvents tbpColor As TabPage
   Friend WithEvents radBlack As RadioButton
   Friend WithEvents radRed As RadioButton
   Friend WithEvents radGreen As RadioButton
   " table page containing font size options
   Friend WithEvents tbpSize As TabPage
   Friend WithEvents radSize12 As RadioButton
   Friend WithEvents radSize16 As RadioButton
   Friend WithEvents radSize20 As RadioButton
   " table page containing text display options
   Friend WithEvents tbpMessage As TabPage
   Friend WithEvents radHello As RadioButton
   Friend WithEvents radGoodbye As RadioButton
   " table page containing about message
   Friend WithEvents tbpAbout As TabPage
   Friend WithEvents lblMessage As Label
   "Required by the Windows Form Designer
   Private components As System.ruponentModel.Container
   "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.radSize12 = New System.Windows.Forms.RadioButton()
      Me.radSize20 = New System.Windows.Forms.RadioButton()
      Me.radHello = New System.Windows.Forms.RadioButton()
      Me.lblDisplay = New System.Windows.Forms.Label()
      Me.tbpMessage = New System.Windows.Forms.TabPage()
      Me.radGoodbye = New System.Windows.Forms.RadioButton()
      Me.tbpAbout = New System.Windows.Forms.TabPage()
      Me.lblMessage = New System.Windows.Forms.Label()
      Me.radSize16 = New System.Windows.Forms.RadioButton()
      Me.tbpColor = New System.Windows.Forms.TabPage()
      Me.radGreen = New System.Windows.Forms.RadioButton()
      Me.radRed = New System.Windows.Forms.RadioButton()
      Me.radBlack = New System.Windows.Forms.RadioButton()
      Me.tbcTextOptions = New System.Windows.Forms.TabControl()
      Me.tbpSize = New System.Windows.Forms.TabPage()
      Me.tbpMessage.SuspendLayout()
      Me.tbpAbout.SuspendLayout()
      Me.tbpColor.SuspendLayout()
      Me.tbcTextOptions.SuspendLayout()
      Me.tbpSize.SuspendLayout()
      Me.SuspendLayout()
      "
      "radSize12
      "
      Me.radSize12.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.radSize12.Location = New System.Drawing.Point(16, 24)
      Me.radSize12.Name = "radSize12"
      Me.radSize12.TabIndex = 0
      Me.radSize12.Text = "12 point"
      "
      "radSize20
      "
      Me.radSize20.Location = New System.Drawing.Point(16, 104)
      Me.radSize20.Name = "radSize20"
      Me.radSize20.TabIndex = 2
      Me.radSize20.Text = "20 point"
      "
      "radHello
      "
      Me.radHello.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.radHello.Location = New System.Drawing.Point(16, 24)
      Me.radHello.Name = "radHello"
      Me.radHello.TabIndex = 0
      Me.radHello.Text = "Hello!"
      "
      "lblDisplay
      "
      Me.lblDisplay.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.lblDisplay.Location = New System.Drawing.Point(16, 184)
      Me.lblDisplay.Name = "lblDisplay"
      Me.lblDisplay.Size = New System.Drawing.Size(272, 40)
      Me.lblDisplay.TabIndex = 1
      Me.lblDisplay.Text = "Hello!"
      Me.lblDisplay.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
      "
      "tbpMessage
      "
      Me.tbpMessage.Controls.AddRange(New System.Windows.Forms.Control() {Me.radGoodbye, Me.radHello})
      Me.tbpMessage.Location = New System.Drawing.Point(4, 22)
      Me.tbpMessage.Name = "tbpMessage"
      Me.tbpMessage.TabIndex = 2
      Me.tbpMessage.Text = "Message"
      "
      "radGoodbye
      "
      Me.radGoodbye.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.radGoodbye.Location = New System.Drawing.Point(16, 64)
      Me.radGoodbye.Name = "radGoodbye"
      Me.radGoodbye.TabIndex = 1
      Me.radGoodbye.Text = "Goodbye!"
      "
      "tbpAbout
      "
      Me.tbpAbout.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblMessage})
      Me.tbpAbout.Location = New System.Drawing.Point(4, 22)
      Me.tbpAbout.Name = "tbpAbout"
      Me.tbpAbout.TabIndex = 3
      Me.tbpAbout.Text = "About"
      "
      "lblMessage
      "
      Me.lblMessage.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.lblMessage.Location = New System.Drawing.Point(16, 16)
      Me.lblMessage.Name = "lblMessage"
      Me.lblMessage.Size = New System.Drawing.Size(248, 104)
      Me.lblMessage.TabIndex = 0
      Me.lblMessage.Text = "Tabs are used to organize controls and conserve screen space."
      "
      "radSize16
      "
      Me.radSize16.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.radSize16.Location = New System.Drawing.Point(16, 64)
      Me.radSize16.Name = "radSize16"
      Me.radSize16.TabIndex = 1
      Me.radSize16.Text = "16 point"
      "
      "tbpColor
      "
      Me.tbpColor.Controls.AddRange(New System.Windows.Forms.Control() {Me.radGreen, Me.radRed, Me.radBlack})
      Me.tbpColor.Location = New System.Drawing.Point(4, 22)
      Me.tbpColor.Name = "tbpColor"
      Me.tbpColor.TabIndex = 0
      Me.tbpColor.Text = "Color"
      "
      "radGreen
      "
      Me.radGreen.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.radGreen.Location = New System.Drawing.Point(16, 104)
      Me.radGreen.Name = "radGreen"
      Me.radGreen.TabIndex = 2
      Me.radGreen.Text = "Green"
      "
      "radRed
      "
      Me.radRed.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.radRed.Location = New System.Drawing.Point(16, 64)
      Me.radRed.Name = "radRed"
      Me.radRed.TabIndex = 1
      Me.radRed.Text = "Red"
      "
      "radBlack
      "
      Me.radBlack.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.radBlack.Location = New System.Drawing.Point(16, 24)
      Me.radBlack.Name = "radBlack"
      Me.radBlack.TabIndex = 0
      Me.radBlack.Text = "Black"
      "
      "tbcTextOptions
      "
      Me.tbcTextOptions.Controls.AddRange(New System.Windows.Forms.Control() {Me.tbpColor, Me.tbpSize, Me.tbpMessage, Me.tbpAbout})
      Me.tbcTextOptions.Location = New System.Drawing.Point(8, 8)
      Me.tbcTextOptions.Name = "tbcTextOptions"
      Me.tbcTextOptions.SelectedIndex = 0
      Me.tbcTextOptions.Size = New System.Drawing.Size(280, 168)
      Me.tbcTextOptions.TabIndex = 0
      "
      "tbpSize
      "
      Me.tbpSize.Controls.AddRange(New System.Windows.Forms.Control() {Me.radSize20, Me.radSize16, Me.radSize12})
      Me.tbpSize.Location = New System.Drawing.Point(4, 22)
      Me.tbpSize.Name = "tbpSize"
      Me.tbpSize.TabIndex = 1
      Me.tbpSize.Text = "Size"
      "
      "FrmTabs
      "
      Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
      Me.ClientSize = New System.Drawing.Size(292, 229)
      Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblDisplay, Me.tbcTextOptions})
      Me.Name = "FrmTabs"
      Me.Text = "Using Tabs"
      Me.tbpMessage.ResumeLayout(False)
      Me.tbpAbout.ResumeLayout(False)
      Me.tbpColor.ResumeLayout(False)
      Me.tbcTextOptions.ResumeLayout(False)
      Me.tbpSize.ResumeLayout(False)
      Me.ResumeLayout(False)
   End Sub
#End Region
   " event handler for black color radio button
   Private Sub radBlack_CheckedChanged _
      (ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles radBlack.CheckedChanged
      lblDisplay.ForeColor = Color.Black
   End Sub 
   
   Private Sub radRed_CheckedChanged _
      (ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles radRed.CheckedChanged
      lblDisplay.ForeColor = Color.Red
   End Sub 
   
   Private Sub radGreen_CheckedChanged _
      (ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles radGreen.CheckedChanged
      lblDisplay.ForeColor = Color.Green
   End Sub 
   
   Private Sub radSize12_CheckedChanged( _
      ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles radSize12.CheckedChanged
      lblDisplay.Font = New Font("Microsoft Sans Serif", 12)
   End Sub 
   Private Sub radSize16_CheckedChanged _
      (ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles radSize16.CheckedChanged
      lblDisplay.Font = New Font("Microsoft Sans Serif", 16)
   End Sub 
   Private Sub radSize20_CheckedChanged _
      (ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles radSize20.CheckedChanged
      lblDisplay.Font = New Font("Microsoft Sans Serif", 20)
   End Sub 
   Private Sub radHello_CheckedChanged _
      (ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles radHello.CheckedChanged
      lblDisplay.Text = "Microsoft Sans Serif"
   End Sub
   
   Private Sub radGoodbye_CheckedChanged _
      (ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles radGoodbye.CheckedChanged
      lblDisplay.Text = "Font Size 20"
   End Sub 
End Class