Home > DeveloperSection > Beginner > RadioButton Control in VB.Net

RadioButton Control in VB.Net


VB.Net VB.Net 
Ratings:
0 Comment(s)
 10312  View(s)
Rate this:

RadioButton Control in VB.Net

RadioButton are used when we need to make multiple sets of choices available, but we want the user to select only one of them. If they click on a second selection after making a first, the first selection is removed and replaced by the second.

Drag and drop RadioButton from toolbox on the window Form.

RadioButton Control in VB.Net

Code:

Public Class Form15

 

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged

        'RadioButton1 value will show in Label3 if RadioButton1 is selected

        Label3.Text = "Selected Language is  " + RadioButton1.Text

    End Sub

 

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged

        'RadioButton2 value will show in Label3 if RadioButton2 is selected

        Label3.Text = "Selected Language is  " + RadioButton2.Text

    End Sub

 

    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged

        'RadioButton3 value will show in Label3 if RadioButton3 is selected

        Label3.Text = "Selected Language is  " + RadioButton3.Text

    End Sub

 

End Class

 

RadioButton Control in VB.Net

When you select any given option then CheckedChanged event will fire and selected value will show in the Label.

 

RadioButton Control in VB.Net

 RadioButton Properties

BackColor:  RadioButton BackColor can be changed through BackColor Properties of RadioButton.

Private Sub Form15_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load  

        ' change BackColor of RadioButton

        RadioButton1.BackColor = Color.Salmon

        RadioButton2.BackColor = Color.Salmon

        RadioButton3.BackColor = Color.Salmon

End Sub

RadioButton Control in VB.Net

CheckAlign: CheckAlign property is used to align the check mark in a RadioButton.

 Appearance: Default value is Normal. Set the value to Button if you want the RadioButton to be displayed as a Button.

'set checkbox appearance as button

    Private Sub Form15_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        RadioButton1.Appearance = Appearance.Button

        RadioButton2.Appearance = Appearance.Button

        RadioButton3.Appearance = Appearance.Button

    End Sub

RadioButton Control in VB.Net

Now RadioButton will show as button.

 


Don't want to miss updates? Please click the below button!

Follow MindStick