Public Sub AddRadioButtons()
Dim rBut1 As New RadioButton()
rBut1.Location = New Point(50, 50)
rBut1.AutoCheck = True
rBut1.Text = "Checked"
rBut1.Checked = True
rBut1.CheckedChanged += New EventHandler(AddressOf rBut_CheckedChanged)
Controls.Add(rBut1)
Dim rBut2 As New RadioButton()
rBut2.Location = New Point(50, 80)
rBut2.AutoCheck = True
rBut2.Text = "UnChecked"
rBut2.Checked = False
rBut2.CheckedChanged += New EventHandler(AddressOf rBut_CheckedChanged)
Controls.Add(rBut2)
End Sub
Private Sub rBut_CheckedChanged(sender As Object, e As System.EventArgs)
If TypeOf sender Is RadioButton Then
Dim radiobutton As RadioButton = TryCast(sender, RadioButton)
If radiobutton.Checked Then
radiobutton.Text = "Checked"
Else
radiobutton.Text = "UnChecked"
End If
End If
End Sub