Using TabControl to display various font settings : TabControl « GUI « VB.Net






Using TabControl to display various font settings

Using TabControl to display various font settings
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.IO

Public Class MainClass

   Shared Sub Main()
        Dim myform As Form = New FrmTabs()
        Application.Run(myform)

   End Sub ' Main

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.ComponentModel.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 = "This is a tab page."
      '
      '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

   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(lblDisplay.Font.Name, 12)
   End Sub

   Private Sub radSize16_CheckedChanged _
      (ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles radSize16.CheckedChanged

      lblDisplay.Font = New Font(lblDisplay.Font.Name, 16)
   End Sub

   Private Sub radSize20_CheckedChanged _
      (ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles radSize20.CheckedChanged

      lblDisplay.Font = New Font(lblDisplay.Font.Name, 20)
   End Sub

   Private Sub radHello_CheckedChanged _
      (ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles radHello.CheckedChanged

      lblDisplay.Text = "Hello!"
   End Sub

   Private Sub radGoodbye_CheckedChanged _
      (ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles radGoodbye.CheckedChanged

      lblDisplay.Text = "Goodbye!"
   End Sub

End Class 
           
       








Related examples in the same category

1.Custom Tab controlCustom Tab control
2.Use Tab ControlUse Tab Control