banner



How Do You Determine In Code Whether A Radiobutton Control Or A Checkbox Control Is Selected?

VB.Cyberspace - RadioButton Control


The RadioButton control is used to provide a set of mutually sectional options. The user can select i radio push in a group. If you need to place more than one grouping of radio buttons in the aforementioned form, yous should place them in different container controls like a GroupBox control.

Let's create three radio buttons by dragging RadioButton controls from the Toolbox and dropping on the form.

VB.Net Radio Button

The Checked belongings of the radio push is used to set the land of a radio button. Y'all can brandish text, image or both on radio push command. You can as well alter the appearance of the radio push button control by using the Advent property.

Properties of the RadioButton Control

The following are some of the unremarkably used properties of the RadioButton control −

Sr.No. Property & Description
1

Advent

Gets or sets a value determining the appearance of the radio button.

2

AutoCheck

Gets or sets a value indicating whether the Checked value and the appearance of the control automatically alter when the control is clicked.

3

CheckAlign

Gets or sets the location of the cheque box portion of the radio button.

four

Checked

Gets or sets a value indicating whether the control is checked.

5

Text

Gets or sets the caption for a radio button.

half dozen

TabStop

Gets or sets a value indicating whether a user tin give focus to the RadioButton command using the TAB key.

Methods of the RadioButton Control

The following are some of the ordinarily used methods of the RadioButton control −

Sr.No. Method Name & Description
one

PerformClick

Generates a Click result for the control, simulating a click by a user.

Events of the RadioButton Control

The following are some of the ordinarily used events of the RadioButton command −

Sr.No Event & Clarification
1

AppearanceChanged

Occurs when the value of the Appearance property of the RadioButton control is inverse.

2

CheckedChanged

Occurs when the value of the Checked property of the RadioButton control is changed.

Consult Microsoft documentation for detailed list of properties, methods and events of the RadioButton control.

Example

In the following example, let usa create two groups of radio buttons and utilise their CheckedChanged events for changing the BackColor and ForeColor property of the class.

Radio Button Example Result Form

Let'southward double click on the radio buttons and put the follow code in the opened window.

Public Form Form1    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load       ' Set the explanation bar text of the class.         Me.Text = "tutorialspont.com"    End Sub     Private Sub RadioButton1_CheckedChanged(sender Every bit Object, _       e Every bit EventArgs) Handles RadioButton1.CheckedChanged       Me.BackColor = Color.Red    End Sub        Private Sub RadioButton2_CheckedChanged(sender As Object, _       e Equally EventArgs) Handles RadioButton2.CheckedChanged       Me.BackColor = Color.Green    Cease Sub        Individual Sub RadioButton3_CheckedChanged(sender As Object, _        east Equally EventArgs) Handles RadioButton3.CheckedChanged       Me.BackColor = Colour.Blue    End Sub       Private Sub RadioButton4_CheckedChanged(sender Equally Object, _       e Equally EventArgs) Handles RadioButton4.CheckedChanged       Me.ForeColor = Color.Blackness    End Sub        Private Sub RadioButton5_CheckedChanged(sender Every bit Object, _        e As EventArgs) Handles RadioButton5.CheckedChanged       Me.ForeColor = Color.White    Stop Sub        Individual Sub RadioButton6_CheckedChanged(sender Equally Object, _       e As EventArgs) Handles RadioButton6.CheckedChanged       Me.ForeColor = Color.Cherry    Cease Sub Terminate Class        

When the above lawmaking is executed and run using Offset push button available at the Microsoft Visual Studio tool bar, it will show the following window −

Result Form

vb.net_basic_controls.htm

How Do You Determine In Code Whether A Radiobutton Control Or A Checkbox Control Is Selected?,

Source: https://www.tutorialspoint.com/vb.net/vb.net_radio_button.htm

Posted by: torrestheivein.blogspot.com

0 Response to "How Do You Determine In Code Whether A Radiobutton Control Or A Checkbox Control Is Selected?"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel