RadioButton Control in VB.NET
In this Article we will demonstrate on RadioButton. its class hierarchy,event with one RadioButton Example.
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 time.it is similar to CheckBox but RadioButtons are displayed as rounded instead of box.
The class hierarchy for this control is as follows:
The default event of the RadioButton is the CheckedChanged event
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
If RadioButton1.Checked Then
TextBox1.Text = "You Clicked" & " " & RadioButton1.Text()
ElseIf RadioButton2.Checked Then
TextBox1.Text = "Your Clicked" & " " & RadioButton2.Text()
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = ""