RadioButton Control in VB.NET

In this Article we will demonstrate on RadioButton. its class hierarchy,event with one RadioButton Example.
  • 8254

The RadioButton control is used to display a Radio Button.RadioButton control allow users to select from a small set of mutually-exclusive, pre-defined choices. The controls allow you to define any number of radio buttons with labels and to arrange them horizontally or vertically.We can select only One RadioButton at a is similar to CheckBox but RadioButtons are displayed as rounded instead of box.

The class hierarchy for this control is as follows:

  • Object
  • Control
  • Webcontrol
  • CheckBox
  • Radiobutton

Radiobutton Event

The default event of the RadioButton is the CheckedChanged event

RadioButton Sample

Drag two radio button's, a textbox and Two button on to the form. Select each radio button and set the GroupName property for each to ABC. If you do not set the GroupName property to a common name then each radio button will act differently and when you make a selection all radio buttons will be rounded. In most cases, you want your users to select only one option from a given list and to accompolish that you need to set the GroupName property. 

The form will look like bolow when we drag all the controls


Then we put this code on the double click of the submit button and reset button

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RadioButton1.Checked Then
TextBox1.Text = "You Clicked" & " " & RadioButton1.Text()
RadioButton2.Checked Then
TextBox1.Text = "Your Clicked" & " " & RadioButton2.Text()
Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
 TextBox1.Text = ""
End Sub




More Articles

© 2020 DotNetHeaven. All rights reserved.