Put RadioButtons to a Tab Control : TabControl « GUI « VB.Net Tutorial






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.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)
        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.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.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








14.37.TabControl
14.37.1.Tab ControlTab Control
14.37.2.TabControl and TabPagesTabControl and TabPages
14.37.3.Add new TabAdd new Tab
14.37.4.Using TabControl to display various font settingsUsing TabControl to display various font settings
14.37.5.Put RadioButtons to a Tab ControlPut RadioButtons to a Tab Control
14.37.6.Custom TabCustom Tab