RadioButton control

  • A RadioButton control is also called an option button.
  • It is very similar to CheckBox control but is it has round shape and you can select only one RadioButton at a time in a group of radio buttons.
  • You can place a RadioButton control on the form by drag and drop it from the toolbox. The RadioButton control looks like as follows:
  • RadioButton Control

Properties of RadioButton Control


Some of the commonly used properties of RadioButton Control are listed below in the Table:


RadioButton Control

Methods of RadioButton Control


Some of the commonly used methods of RadioButton Control are listed below in the Table:


RadioButton Control

Events of RadioButton Control


Some of the commonly used Events of Radio Control are listed below in the Table:


RadioButton Control

Example

Here is a simple example of RadioButton control. To understand the use of the RadioButton control follows the given steps:


  • Add Two RadioButton controls and a TextBox control on the form from the toolbox.
  • Now double click on RadioButton1 and add the following code in its code-window:
  • Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton1.CheckedChanged
    If RadioButton1.Checked = True Then
    TextBox1.Text = "You clicked at RadioButton1"
    End If
    End Sub

  • Now double click on RadioButton2 and add the following code in its code-window:
  • Private Sub RadioButton2_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton2.CheckedChanged
    If RadioButton2.Checked = True Then
    TextBox1.Text = "You clicked at RadioButton2"
    End If
    End Sub

  • Now run the application using F5 key. This will generate a Form in which first radio button is selected by default so a message appears in the text box.
  • Click on the RadioButton2 . This will show the message changes in the textbox:
  • RadioButton Control