RadioButton in Visual Basic .NET
Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013
This lesson describes the RadioButton control
This control lets the user pick from among a set of options, and if the user checks one RadioButton, all others with the same parent become unchecked.
For example, say that you want to let the user select one of the values High, Medium, and Low. You could add three RadioButtons to your form with those captions, and then when the user clicks one button, Visual Basic selects it and deselects the others.
All the RadioButton controls within a particular container are part of the same RadioButton group, which means that if the user clicks a certain RadioButton, the other buttons in the same group will be deselected.
The RadioButton control's most useful events are Click, which occurs when the user clicks the control, and CheckedChanged, which occurs when the control is checked or unchecked either because the user clicked a RadioButton in the group or because the code changed the button's state.
Private Sub High_CheckedChanged(sender As Object, e As EventArgs) Handles High.CheckedChanged If High.Checked = True Then MessageBox.Show("Response time with high priority, usually 1 day.") End If End Sub
Private Sub High_Click(sender As Object, e As EventArgs) Handles High.Click MessageBox.Show("Please call us, if you need help in selecting the right priority.") End SubPrevious Lesson | Next Lesson