The following tutorial demonstrates creating two groups of radio buttons that act independently of one another. Choices are reflected in a label as they are selected.
- Drop two RadGroupBoxes on the form.
- Drop three RadRadioButtons on the first groupbox.
Set their Text properties to "Small", "Medium" and "Large".
- Drop three RadRadioButtons on the second groupbox.
Set their Text properties to "Latte", "Mocha", and "Hot Chocolate".
- Drop a RadLabel on the form.
Set the name of the RadLabel to "lblStatus".
- Hold down the Shift key and select all six RadRadioButtons with the mouse.
- Click the Events tab of the Properties Window.
- Double click the ToggleStateChanged event to create an event handler. Replace the code with the following:
Copy[C#] Handling the ToggleStateChanged Event
void radRadioButton1_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
lblStatus.Text = (sender as RadRadioButton).Text + " is selected";
}
Copy[VB.NET] Handling the ToggleStateChanged Event
Private Sub radRadioButton1_ToggleStateChanged(ByVal sender As Object, ByVal args As StateChangedEventArgs)
lblStatus.Text = (TryCast(sender, RadRadioButton)).Text + " is selected"
End Sub - Press F5 to run the application. Notice that selections made on radio buttons in the panel are independent of the radio button choices on the form.
RadRadioButton determines the radio groups by the control parent. All RadRadioButtons sharing the same parent e.g. RadGroupBox, RadPanel or a Form will be part of one group.