VB.Net Tutorial/GUI/RadioButton — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 12:56, 26 мая 2010
Содержание
Get selected RadioButton
Option Strict On
Imports System.Windows.Forms
public class RadioButtonState
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
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton
Friend WithEvents Button1 As System.Windows.Forms.Button
"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.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.RadioButton3 = New System.Windows.Forms.RadioButton()
Me.RadioButton2 = New System.Windows.Forms.RadioButton()
Me.RadioButton1 = New System.Windows.Forms.RadioButton()
Me.Button1 = New System.Windows.Forms.Button()
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
"
"GroupBox1
"
Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.RadioButton3, Me.RadioButton2, Me.RadioButton1})
Me.GroupBox1.Location = New System.Drawing.Point(40, 32)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(240, 160)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Choose a button:"
"
"RadioButton3
"
Me.RadioButton3.Location = New System.Drawing.Point(40, 104)
Me.RadioButton3.Name = "RadioButton3"
Me.RadioButton3.Size = New System.Drawing.Size(144, 24)
Me.RadioButton3.TabIndex = 2
Me.RadioButton3.Text = "RadioButton3"
"
"RadioButton2
"
Me.RadioButton2.Location = New System.Drawing.Point(40, 64)
Me.RadioButton2.Name = "RadioButton2"
Me.RadioButton2.Size = New System.Drawing.Size(144, 24)
Me.RadioButton2.TabIndex = 1
Me.RadioButton2.Text = "RadioButton2"
"
"RadioButton1
"
Me.RadioButton1.Checked = True
Me.RadioButton1.Location = New System.Drawing.Point(40, 32)
Me.RadioButton1.Name = "RadioButton1"
Me.RadioButton1.Size = New System.Drawing.Size(144, 24)
Me.RadioButton1.TabIndex = 0
Me.RadioButton1.TabStop = True
Me.RadioButton1.Text = "RadioButton1"
"
"Button1
"
Me.Button1.Location = New System.Drawing.Point(56, 216)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(168, 23)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Which is Selected?"
"
"Form1
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.GroupBox1})
Me.Name = "Form1"
Me.Text = "Form1"
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub RadioButton1_CheckedChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged, _
RadioButton2.CheckedChanged, RadioButton3.CheckedChanged
End Sub
Private Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim c As Object
For Each c In Me.GroupBox1.Controls
If TypeOf (c) Is RadioButton Then
Dim rb As RadioButton = CType(c, RadioButton)
If rb.Checked = True Then
MsgBox(CStr(rb.Name) & " is selected")
Exit For
End If
End If
Next
End Sub
End Class
RadioButtons in a GroupBox
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class RadioButtonInGroupBox
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 Label1 As System.Windows.Forms.Label
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton4 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton5 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton6 As System.Windows.Forms.RadioButton
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.GroupBox2 = New System.Windows.Forms.GroupBox
Me.RadioButton1 = New System.Windows.Forms.RadioButton
Me.RadioButton2 = New System.Windows.Forms.RadioButton
Me.RadioButton3 = New System.Windows.Forms.RadioButton
Me.RadioButton4 = New System.Windows.Forms.RadioButton
Me.RadioButton5 = New System.Windows.Forms.RadioButton
Me.RadioButton6 = New System.Windows.Forms.RadioButton
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.GroupBox1.SuspendLayout()
Me.GroupBox2.SuspendLayout()
Me.SuspendLayout()
"
"Label1
"
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(0, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(208, 40)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Group Boxes"
"
"GroupBox1
"
Me.GroupBox1.Controls.Add(Me.RadioButton3)
Me.GroupBox1.Controls.Add(Me.RadioButton2)
Me.GroupBox1.Controls.Add(Me.RadioButton1)
Me.GroupBox1.Location = New System.Drawing.Point(8, 48)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(136, 176)
Me.GroupBox1.TabIndex = 1
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "GroupBox1"
"
"GroupBox2
"
Me.GroupBox2.Controls.Add(Me.RadioButton6)
Me.GroupBox2.Controls.Add(Me.RadioButton5)
Me.GroupBox2.Controls.Add(Me.RadioButton4)
Me.GroupBox2.Location = New System.Drawing.Point(152, 48)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(136, 176)
Me.GroupBox2.TabIndex = 2
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "GroupBox2"
"
"RadioButton1
"
Me.RadioButton1.Location = New System.Drawing.Point(16, 32)
Me.RadioButton1.Name = "RadioButton1"
Me.RadioButton1.TabIndex = 0
Me.RadioButton1.Text = "RadioButton1"
"
"RadioButton2
"
Me.RadioButton2.Location = New System.Drawing.Point(16, 72)
Me.RadioButton2.Name = "RadioButton2"
Me.RadioButton2.TabIndex = 1
Me.RadioButton2.Text = "RadioButton2"
"
"RadioButton3
"
Me.RadioButton3.Location = New System.Drawing.Point(16, 112)
Me.RadioButton3.Name = "RadioButton3"
Me.RadioButton3.TabIndex = 2
Me.RadioButton3.Text = "RadioButton3"
"
"RadioButton4
"
Me.RadioButton4.Location = New System.Drawing.Point(16, 32)
Me.RadioButton4.Name = "RadioButton4"
Me.RadioButton4.TabIndex = 0
Me.RadioButton4.Text = "RadioButton4"
"
"RadioButton5
"
Me.RadioButton5.Location = New System.Drawing.Point(16, 72)
Me.RadioButton5.Name = "RadioButton5"
Me.RadioButton5.TabIndex = 1
Me.RadioButton5.Text = "RadioButton5"
"
"RadioButton6
"
Me.RadioButton6.Location = New System.Drawing.Point(16, 112)
Me.RadioButton6.Name = "RadioButton6"
Me.RadioButton6.TabIndex = 2
Me.RadioButton6.Text = "RadioButton6"
"
"TextBox1
"
Me.TextBox1.Location = New System.Drawing.Point(8, 240)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(280, 20)
Me.TextBox1.TabIndex = 3
Me.TextBox1.Text = ""
"
"Form1
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TextBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox2.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
TextBox1.Text = "You clicked radio button 1."
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
TextBox1.Text = "You clicked radio button 2."
End Sub
Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
TextBox1.Text = "You clicked radio button 3."
End Sub
Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
TextBox1.Text = "You clicked radio button 4."
End Sub
Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
TextBox1.Text = "You clicked radio button 5."
End Sub
Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged
TextBox1.Text = "You clicked radio button 6."
End Sub
End Class
Toggle Buttons
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class RadioButtonToggleButton
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 RadioButton1 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.RadioButton1 = New System.Windows.Forms.RadioButton
Me.RadioButton2 = New System.Windows.Forms.RadioButton
Me.RadioButton3 = New System.Windows.Forms.RadioButton
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
"
"RadioButton1
"
Me.RadioButton1.Appearance = System.Windows.Forms.Appearance.Button
Me.RadioButton1.Location = New System.Drawing.Point(96, 64)
Me.RadioButton1.Name = "RadioButton1"
Me.RadioButton1.TabIndex = 0
Me.RadioButton1.Text = "Radio Button 1"
"
"RadioButton2
"
Me.RadioButton2.Appearance = System.Windows.Forms.Appearance.Button
Me.RadioButton2.Location = New System.Drawing.Point(96, 112)
Me.RadioButton2.Name = "RadioButton2"
Me.RadioButton2.TabIndex = 1
Me.RadioButton2.Text = "Radio Button 2"
"
"RadioButton3
"
Me.RadioButton3.Appearance = System.Windows.Forms.Appearance.Button
Me.RadioButton3.Location = New System.Drawing.Point(96, 160)
Me.RadioButton3.Name = "RadioButton3"
Me.RadioButton3.TabIndex = 2
Me.RadioButton3.Text = "Radio Button 3"
"
"TextBox1
"
Me.TextBox1.Location = New System.Drawing.Point(40, 216)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(200, 20)
Me.TextBox1.TabIndex = 3
Me.TextBox1.Text = ""
"
"Form1
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.RadioButton3)
Me.Controls.Add(Me.RadioButton2)
Me.Controls.Add(Me.RadioButton1)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
TextBox1.Text = "You clicked button 1."
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
TextBox1.Text = "You clicked button 2."
End Sub
Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
TextBox1.Text = "You clicked button 3."
End Sub
End Class
Use RadioButton to control the LineCap
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ruponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Drawing.Drawing2D
public class LineJoinRadioButton
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 groupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents MiterClippedRadBtn As System.Windows.Forms.RadioButton
Friend WithEvents RoundRadBtn As System.Windows.Forms.RadioButton
Friend WithEvents MiterRadBtn As System.Windows.Forms.RadioButton
Friend WithEvents BevelRadBtn As System.Windows.Forms.RadioButton
Friend WithEvents ApplyJoin As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.groupBox1 = New System.Windows.Forms.GroupBox
Me.MiterClippedRadBtn = New System.Windows.Forms.RadioButton
Me.RoundRadBtn = New System.Windows.Forms.RadioButton
Me.MiterRadBtn = New System.Windows.Forms.RadioButton
Me.BevelRadBtn = New System.Windows.Forms.RadioButton
Me.ApplyJoin = New System.Windows.Forms.Button
Me.groupBox1.SuspendLayout()
Me.SuspendLayout()
"
"groupBox1
"
Me.groupBox1.Controls.Add(Me.MiterClippedRadBtn)
Me.groupBox1.Controls.Add(Me.RoundRadBtn)
Me.groupBox1.Controls.Add(Me.MiterRadBtn)
Me.groupBox1.Controls.Add(Me.BevelRadBtn)
Me.groupBox1.Location = New System.Drawing.Point(320, 18)
Me.groupBox1.Name = "groupBox1"
Me.groupBox1.Size = New System.Drawing.Size(152, 152)
Me.groupBox1.TabIndex = 3
Me.groupBox1.TabStop = False
Me.groupBox1.Text = "Line Join"
"
"MiterClippedRadBtn
"
Me.MiterClippedRadBtn.Location = New System.Drawing.Point(16, 88)
Me.MiterClippedRadBtn.Name = "MiterClippedRadBtn"
Me.MiterClippedRadBtn.Size = New System.Drawing.Size(120, 24)
Me.MiterClippedRadBtn.TabIndex = 3
Me.MiterClippedRadBtn.Text = "Miter Clipped"
"
"RoundRadBtn
"
Me.RoundRadBtn.Location = New System.Drawing.Point(16, 120)
Me.RoundRadBtn.Name = "RoundRadBtn"
Me.RoundRadBtn.Size = New System.Drawing.Size(112, 24)
Me.RoundRadBtn.TabIndex = 2
Me.RoundRadBtn.Text = "Round"
"
"MiterRadBtn
"
Me.MiterRadBtn.Location = New System.Drawing.Point(16, 56)
Me.MiterRadBtn.Name = "MiterRadBtn"
Me.MiterRadBtn.Size = New System.Drawing.Size(120, 24)
Me.MiterRadBtn.TabIndex = 1
Me.MiterRadBtn.Text = "Miter"
"
"BevelRadBtn
"
Me.BevelRadBtn.Checked = True
Me.BevelRadBtn.Location = New System.Drawing.Point(16, 24)
Me.BevelRadBtn.Name = "BevelRadBtn"
Me.BevelRadBtn.Size = New System.Drawing.Size(112, 24)
Me.BevelRadBtn.TabIndex = 0
Me.BevelRadBtn.TabStop = True
Me.BevelRadBtn.Text = "Bevel"
"
"ApplyJoin
"
Me.ApplyJoin.Location = New System.Drawing.Point(344, 194)
Me.ApplyJoin.Name = "ApplyJoin"
Me.ApplyJoin.Size = New System.Drawing.Size(112, 32)
Me.ApplyJoin.TabIndex = 2
Me.ApplyJoin.Text = "Apply LineJoin"
"
"Form1
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(488, 245)
Me.Controls.Add(Me.groupBox1)
Me.Controls.Add(Me.ApplyJoin)
Me.Name = "Form1"
Me.Text = "Form1"
Me.groupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub ApplyJoin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ApplyJoin.Click
Dim g As Graphics = Me.CreateGraphics()
g.Clear(Me.BackColor)
If BevelRadBtn.Checked Then
DrawJoinedLines(g, LineJoin.Bevel)
End If
If MiterRadBtn.Checked Then
DrawJoinedLines(g, LineJoin.Miter)
End If
If MiterClippedRadBtn.Checked Then
DrawJoinedLines(g, LineJoin.MiterClipped)
End If
If RoundRadBtn.Checked Then
DrawJoinedLines(g, LineJoin.Round)
End If
g.Dispose()
End Sub
Private Sub DrawJoinedLines(ByVal g As Graphics, ByVal joinType As LineJoin)
g.SmoothingMode = SmoothingMode.AntiAlias
Dim redPen As New Pen(Color.Red, 20)
redPen.LineJoin = joinType
Dim pts As Point() = {New Point(10, 20), New Point(50, 20), New Point(80, 60), New Point(50, 150), New Point(150, 150)}
Dim pts1 As Point() = {New Point(20, 20), New Point(300, 20), New Point(30, 120), New Point(200, 120), New Point(200, 20)}
g.DrawLines(redPen, pts)
g.DrawLines(redPen, pts1)
redPen.Dispose()
End Sub "DrawJoinedLines
End Class
Use RadioButton to set font
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class UseCheckBoxRadioButtonSetFont
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Inherits System.Windows.Forms.Form
Private LabelStyle As FontStyle
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 Label1 As System.Windows.Forms.Label
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents RadioButton4 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton5 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton6 As System.Windows.Forms.RadioButton
Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox
Friend WithEvents CheckBox2 As System.Windows.Forms.CheckBox
Friend WithEvents CheckBox3 As System.Windows.Forms.CheckBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.RadioButton1 = New System.Windows.Forms.RadioButton
Me.RadioButton2 = New System.Windows.Forms.RadioButton
Me.RadioButton3 = New System.Windows.Forms.RadioButton
Me.GroupBox2 = New System.Windows.Forms.GroupBox
Me.RadioButton4 = New System.Windows.Forms.RadioButton
Me.RadioButton5 = New System.Windows.Forms.RadioButton
Me.RadioButton6 = New System.Windows.Forms.RadioButton
Me.GroupBox3 = New System.Windows.Forms.GroupBox
Me.CheckBox1 = New System.Windows.Forms.CheckBox
Me.CheckBox2 = New System.Windows.Forms.CheckBox
Me.CheckBox3 = New System.Windows.Forms.CheckBox
Me.GroupBox1.SuspendLayout()
Me.GroupBox2.SuspendLayout()
Me.GroupBox3.SuspendLayout()
Me.SuspendLayout()
"
"Label1
"
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(24, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(288, 88)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Visual Basic.NET"
"
"GroupBox1
"
Me.GroupBox1.Controls.Add(Me.RadioButton3)
Me.GroupBox1.Controls.Add(Me.RadioButton2)
Me.GroupBox1.Controls.Add(Me.RadioButton1)
Me.GroupBox1.Location = New System.Drawing.Point(32, 136)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(72, 120)
Me.GroupBox1.TabIndex = 1
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Color"
"
"RadioButton1
"
Me.RadioButton1.Location = New System.Drawing.Point(8, 24)
Me.RadioButton1.Name = "RadioButton1"
Me.RadioButton1.Size = New System.Drawing.Size(56, 16)
Me.RadioButton1.TabIndex = 0
Me.RadioButton1.Text = "Red"
"
"RadioButton2
"
Me.RadioButton2.Location = New System.Drawing.Point(8, 48)
Me.RadioButton2.Name = "RadioButton2"
Me.RadioButton2.Size = New System.Drawing.Size(56, 16)
Me.RadioButton2.TabIndex = 1
Me.RadioButton2.Text = "Yellow"
"
"RadioButton3
"
Me.RadioButton3.Location = New System.Drawing.Point(8, 72)
Me.RadioButton3.Name = "RadioButton3"
Me.RadioButton3.Size = New System.Drawing.Size(56, 24)
Me.RadioButton3.TabIndex = 2
Me.RadioButton3.Text = "Green"
"
"GroupBox2
"
Me.GroupBox2.Controls.Add(Me.RadioButton6)
Me.GroupBox2.Controls.Add(Me.RadioButton5)
Me.GroupBox2.Controls.Add(Me.RadioButton4)
Me.GroupBox2.Location = New System.Drawing.Point(128, 136)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(80, 120)
Me.GroupBox2.TabIndex = 2
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "Font Size"
"
"RadioButton4
"
Me.RadioButton4.Location = New System.Drawing.Point(16, 24)
Me.RadioButton4.Name = "RadioButton4"
Me.RadioButton4.Size = New System.Drawing.Size(48, 16)
Me.RadioButton4.TabIndex = 0
Me.RadioButton4.Text = "10"
"
"RadioButton5
"
Me.RadioButton5.Location = New System.Drawing.Point(16, 48)
Me.RadioButton5.Name = "RadioButton5"
Me.RadioButton5.Size = New System.Drawing.Size(56, 24)
Me.RadioButton5.TabIndex = 1
Me.RadioButton5.Text = "20"
"
"RadioButton6
"
Me.RadioButton6.Location = New System.Drawing.Point(16, 80)
Me.RadioButton6.Name = "RadioButton6"
Me.RadioButton6.Size = New System.Drawing.Size(56, 24)
Me.RadioButton6.TabIndex = 2
Me.RadioButton6.Text = "30"
"
"GroupBox3
"
Me.GroupBox3.Controls.Add(Me.CheckBox3)
Me.GroupBox3.Controls.Add(Me.CheckBox2)
Me.GroupBox3.Controls.Add(Me.CheckBox1)
Me.GroupBox3.Location = New System.Drawing.Point(224, 144)
Me.GroupBox3.Name = "GroupBox3"
Me.GroupBox3.Size = New System.Drawing.Size(88, 120)
Me.GroupBox3.TabIndex = 3
Me.GroupBox3.TabStop = False
Me.GroupBox3.Text = "Other"
"
"CheckBox1
"
Me.CheckBox1.Location = New System.Drawing.Point(16, 16)
Me.CheckBox1.Name = "CheckBox1"
Me.CheckBox1.Size = New System.Drawing.Size(64, 24)
Me.CheckBox1.TabIndex = 0
Me.CheckBox1.Text = "Italic"
"
"CheckBox2
"
Me.CheckBox2.Location = New System.Drawing.Point(16, 48)
Me.CheckBox2.Name = "CheckBox2"
Me.CheckBox2.Size = New System.Drawing.Size(48, 24)
Me.CheckBox2.TabIndex = 1
Me.CheckBox2.Text = "Bold"
"
"CheckBox3
"
Me.CheckBox3.Location = New System.Drawing.Point(16, 80)
Me.CheckBox3.Name = "CheckBox3"
Me.CheckBox3.Size = New System.Drawing.Size(64, 24)
Me.CheckBox3.TabIndex = 2
Me.CheckBox3.Text = "Underline"
"
"Form1
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(328, 278)
Me.Controls.Add(Me.GroupBox3)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "Font Setting"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox2.ResumeLayout(False)
Me.GroupBox3.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
Label1.ForeColor = Color.Red
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
Label1.ForeColor = Color.Yellow
End Sub
Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
Label1.ForeColor = Color.Green
End Sub
Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
Label1.Font = New Font(Label1.Font.FontFamily, 10)
End Sub
Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
Label1.Font = New Font(Label1.Font.FontFamily, 20)
End Sub
Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged
Label1.Font = New Font(Label1.Font.FontFamily, 30)
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
LabelStyle = LabelStyle Xor FontStyle.Italic
Label1.Font = New Font(Label1.Font, LabelStyle)
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
LabelStyle = LabelStyle Xor FontStyle.Bold
Label1.Font = New Font(Label1.Font, LabelStyle)
End Sub
Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
LabelStyle = LabelStyle Xor FontStyle.Underline
Label1.Font = New Font(Label1.Font, LabelStyle)
End Sub
End Class
Using RadioButtons to set message window options.
Imports System.Windows.Forms
public class RadioButtonAction
public Shared Sub Main
Application.Run(New FrmRadioButton)
End Sub
End class
Public Class FrmRadioButton
Inherits System.Windows.Forms.Form
Private iconType As MessageBoxIcon
Private buttonType As MessageBoxButtons
#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
Friend WithEvents iconGroupBox As System.Windows.Forms.GroupBox
Friend WithEvents buttonTypeGroupBox As System.Windows.Forms.GroupBox
Friend WithEvents radRetryCancel As System.Windows.Forms.RadioButton
Friend WithEvents radYesNo As System.Windows.Forms.RadioButton
Friend WithEvents radAbortRetryIgnore As System.Windows.Forms.RadioButton
Friend WithEvents radOk As System.Windows.Forms.RadioButton
Friend WithEvents radWarning As System.Windows.Forms.RadioButton
Friend WithEvents radStop As System.Windows.Forms.RadioButton
Friend WithEvents radQuestion As System.Windows.Forms.RadioButton
Friend WithEvents radInformation As System.Windows.Forms.RadioButton
Friend WithEvents radHand As System.Windows.Forms.RadioButton
Friend WithEvents radExclamation As System.Windows.Forms.RadioButton
Friend WithEvents radError As System.Windows.Forms.RadioButton
Friend WithEvents radAsterisk As System.Windows.Forms.RadioButton
Friend WithEvents cmdDisplay As System.Windows.Forms.Button
Friend WithEvents lblDisplay As System.Windows.Forms.Label
Friend WithEvents radOkCancel As System.Windows.Forms.RadioButton
Friend WithEvents radYesNoCancel As System.Windows.Forms.RadioButton
"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.radAbortRetryIgnore = New System.Windows.Forms.RadioButton()
Me.radStop = New System.Windows.Forms.RadioButton()
Me.radYesNo = New System.Windows.Forms.RadioButton()
Me.iconGroupBox = New System.Windows.Forms.GroupBox()
Me.radWarning = New System.Windows.Forms.RadioButton()
Me.radQuestion = New System.Windows.Forms.RadioButton()
Me.radInformation = New System.Windows.Forms.RadioButton()
Me.radHand = New System.Windows.Forms.RadioButton()
Me.radExclamation = New System.Windows.Forms.RadioButton()
Me.radError = New System.Windows.Forms.RadioButton()
Me.radAsterisk = New System.Windows.Forms.RadioButton()
Me.radYesNoCancel = New System.Windows.Forms.RadioButton()
Me.radOk = New System.Windows.Forms.RadioButton()
Me.cmdDisplay = New System.Windows.Forms.Button()
Me.lblDisplay = New System.Windows.Forms.Label()
Me.buttonTypeGroupBox = New System.Windows.Forms.GroupBox()
Me.radRetryCancel = New System.Windows.Forms.RadioButton()
Me.radOkCancel = New System.Windows.Forms.RadioButton()
Me.iconGroupBox.SuspendLayout()
Me.buttonTypeGroupBox.SuspendLayout()
Me.SuspendLayout()
"
"radAbortRetryIgnore
"
Me.radAbortRetryIgnore.Location = New System.Drawing.Point(16, 88)
Me.radAbortRetryIgnore.Name = "radAbortRetryIgnore"
Me.radAbortRetryIgnore.Size = New System.Drawing.Size(120, 24)
Me.radAbortRetryIgnore.TabIndex = 2
Me.radAbortRetryIgnore.Text = "AbortRetryIgnore"
"
"radStop
"
Me.radStop.Location = New System.Drawing.Point(16, 240)
Me.radStop.Name = "radStop"
Me.radStop.Size = New System.Drawing.Size(128, 24)
Me.radStop.TabIndex = 6
Me.radStop.Text = "Stop"
"
"radYesNo
"
Me.radYesNo.Location = New System.Drawing.Point(16, 160)
Me.radYesNo.Name = "radYesNo"
Me.radYesNo.Size = New System.Drawing.Size(120, 16)
Me.radYesNo.TabIndex = 4
Me.radYesNo.Text = "YesNo"
"
"iconGroupBox
"
Me.iconGroupBox.Controls.AddRange(New System.Windows.Forms.Control() {Me.radWarning, Me.radStop, Me.radQuestion, Me.radInformation, Me.radHand, Me.radExclamation, Me.radError, Me.radAsterisk})
Me.iconGroupBox.Location = New System.Drawing.Point(200, 16)
Me.iconGroupBox.Name = "iconGroupBox"
Me.iconGroupBox.Size = New System.Drawing.Size(160, 304)
Me.iconGroupBox.TabIndex = 3
Me.iconGroupBox.TabStop = False
Me.iconGroupBox.Text = "Icon"
"
"radWarning
"
Me.radWarning.Location = New System.Drawing.Point(16, 272)
Me.radWarning.Name = "radWarning"
Me.radWarning.Size = New System.Drawing.Size(128, 24)
Me.radWarning.TabIndex = 7
Me.radWarning.Text = "Warning"
"
"radQuestion
"
Me.radQuestion.Location = New System.Drawing.Point(16, 208)
Me.radQuestion.Name = "radQuestion"
Me.radQuestion.Size = New System.Drawing.Size(128, 24)
Me.radQuestion.TabIndex = 5
Me.radQuestion.Text = "Question"
"
"radInformation
"
Me.radInformation.Location = New System.Drawing.Point(16, 168)
Me.radInformation.Name = "radInformation"
Me.radInformation.Size = New System.Drawing.Size(128, 24)
Me.radInformation.TabIndex = 4
Me.radInformation.Text = "Information"
"
"radHand
"
Me.radHand.Location = New System.Drawing.Point(16, 128)
Me.radHand.Name = "radHand"
Me.radHand.Size = New System.Drawing.Size(128, 24)
Me.radHand.TabIndex = 3
Me.radHand.Text = "Hand"
"
"radExclamation
"
Me.radExclamation.Location = New System.Drawing.Point(16, 88)
Me.radExclamation.Name = "radExclamation"
Me.radExclamation.Size = New System.Drawing.Size(136, 24)
Me.radExclamation.TabIndex = 2
Me.radExclamation.Text = "Exclamation"
"
"radError
"
Me.radError.Location = New System.Drawing.Point(16, 48)
Me.radError.Name = "radError"
Me.radError.Size = New System.Drawing.Size(136, 24)
Me.radError.TabIndex = 1
Me.radError.Text = "Error"
"
"radAsterisk
"
Me.radAsterisk.Location = New System.Drawing.Point(16, 16)
Me.radAsterisk.Name = "radAsterisk"
Me.radAsterisk.Size = New System.Drawing.Size(136, 24)
Me.radAsterisk.TabIndex = 0
Me.radAsterisk.Text = "Asterisk"
"
"radYesNoCancel
"
Me.radYesNoCancel.Location = New System.Drawing.Point(16, 120)
Me.radYesNoCancel.Name = "radYesNoCancel"
Me.radYesNoCancel.Size = New System.Drawing.Size(120, 24)
Me.radYesNoCancel.TabIndex = 3
Me.radYesNoCancel.Text = "YesNoCancel"
"
"radOk
"
Me.radOk.Location = New System.Drawing.Point(16, 24)
Me.radOk.Name = "radOk"
Me.radOk.Size = New System.Drawing.Size(112, 16)
Me.radOk.TabIndex = 0
Me.radOk.Text = "OK"
"
"cmdDisplay
"
Me.cmdDisplay.Location = New System.Drawing.Point(32, 240)
Me.cmdDisplay.Name = "cmdDisplay"
Me.cmdDisplay.Size = New System.Drawing.Size(112, 40)
Me.cmdDisplay.TabIndex = 1
Me.cmdDisplay.Text = "Display"
"
"lblDisplay
"
Me.lblDisplay.Location = New System.Drawing.Point(24, 296)
Me.lblDisplay.Name = "lblDisplay"
Me.lblDisplay.Size = New System.Drawing.Size(144, 24)
Me.lblDisplay.TabIndex = 5
"
"buttonTypeGroupBox
"
Me.buttonTypeGroupBox.Controls.AddRange(New System.Windows.Forms.Control() {Me.radRetryCancel, Me.radYesNo, Me.radYesNoCancel, Me.radAbortRetryIgnore, Me.radOkCancel, Me.radOk})
Me.buttonTypeGroupBox.Location = New System.Drawing.Point(16, 16)
Me.buttonTypeGroupBox.Name = "buttonTypeGroupBox"
Me.buttonTypeGroupBox.Size = New System.Drawing.Size(144, 216)
Me.buttonTypeGroupBox.TabIndex = 2
Me.buttonTypeGroupBox.TabStop = False
Me.buttonTypeGroupBox.Text = "Button Type"
"
"radRetryCancel
"
Me.radRetryCancel.Location = New System.Drawing.Point(16, 192)
Me.radRetryCancel.Name = "radRetryCancel"
Me.radRetryCancel.Size = New System.Drawing.Size(104, 16)
Me.radRetryCancel.TabIndex = 5
Me.radRetryCancel.Text = "RetryCancel"
"
"radOkCancel
"
Me.radOkCancel.Location = New System.Drawing.Point(16, 56)
Me.radOkCancel.Name = "radOkCancel"
Me.radOkCancel.Size = New System.Drawing.Size(120, 24)
Me.radOkCancel.TabIndex = 1
Me.radOkCancel.Text = "OKCancel"
"
"FrmRadioButton
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(384, 333)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblDisplay, Me.iconGroupBox, Me.buttonTypeGroupBox, Me.cmdDisplay})
Me.Name = "FrmRadioButton"
Me.Text = "RadioButtonTest"
Me.iconGroupBox.ResumeLayout(False)
Me.buttonTypeGroupBox.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub cmdDisplay_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles cmdDisplay.Click
Dim dialog As DialogResult = MessageBox.Show( _
"Your message", "Title", _
buttonType, iconType)
Select Case dialog
Case DialogResult.OK
lblDisplay.Text = "OK was pressed"
Case DialogResult.Cancel
lblDisplay.Text = "Cancel was pressed"
Case DialogResult.Abort
lblDisplay.Text = "Abort was pressed"
Case DialogResult.Retry
lblDisplay.Text = "Retry was pressed"
Case DialogResult.Ignore
lblDisplay.Text = "Ignore was pressed"
Case DialogResult.Yes
lblDisplay.Text = "Yes was pressed"
Case DialogResult.No
lblDisplay.Text = "No was pressed"
End Select
End Sub " cmdDisplay_Click
Private Sub radOk_CheckedChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles radOk.CheckedChanged
buttonType = MessageBoxButtons.OK
End Sub
Private Sub radOkCancel_CheckedChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles radOkCancel.CheckedChanged
buttonType = MessageBoxButtons.OKCancel
End Sub
Private Sub radAbortRetryIgnore_CheckedChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles radAbortRetryIgnore.CheckedChanged
buttonType = MessageBoxButtons.AbortRetryIgnore
End Sub
Private Sub radYesNoCancel_CheckedChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles radYesNoCancel.CheckedChanged
buttonType = MessageBoxButtons.YesNoCancel
End Sub
Private Sub radYesNo_CheckedChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles radYesNo.CheckedChanged
buttonType = MessageBoxButtons.YesNo
End Sub
Private Sub radRetryCancel_CheckedChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles radRetryCancel.CheckedChanged
buttonType = MessageBoxButtons.RetryCancel
End Sub
Private Sub radAsterisk_CheckedChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles radAsterisk.CheckedChanged
iconType = MessageBoxIcon.Asterisk
End Sub
Private Sub radError_CheckedChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles radError.CheckedChanged
iconType = MessageBoxIcon.Error
End Sub
Private Sub radExclamation_CheckedChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles radExclamation.CheckedChanged
iconType = MessageBoxIcon.Exclamation
End Sub
Private Sub radHand_CheckedChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles radHand.CheckedChanged
iconType = MessageBoxIcon.Hand
End Sub
Private Sub radInformation_CheckedChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles radInformation.CheckedChanged
iconType = MessageBoxIcon.Information
End Sub
Private Sub radQuestion_CheckedChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles radQuestion.CheckedChanged
iconType = MessageBoxIcon.Question
End Sub
Private Sub radStop_CheckedChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles radStop.CheckedChanged
iconType = MessageBoxIcon.Stop
End Sub
Private Sub radWarning_CheckedChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles radWarning.CheckedChanged
iconType = MessageBoxIcon.Warning
End Sub
End Class