Telerik UI for WinForms

State Properties

The ToggleState property is responsible for setting the state of RadRadioButton. 


You can handle the ToggleStateChanged event of RadRadioButton to take action when the user toggles the button. The event handler is passed a StateChangedEventArgs parameter that includes a ToggleState member.

[C#] Handling ToggleStateChanged event Copy imageCopy
void radRadioButton2_ToggleStateChanged(object sender, StateChangedEventArgs args)
[VB.NET] Handling ToggleStateChanged event Copy imageCopy
Private Sub radRadioButton2_ToggleStateChanged(ByVal sender As Object, ByVal args As StateChangedEventArgs)
End Sub

You can also handle the ToggleStateChanging event. This event provides an opportunity to cancel the toggle state change. The StateChangingEventArgs passed as a parameter to the event handler have NewValue and OldValue ToggleState members and a Boolean Cancel member. NewValue holds the value of ToggleState that will be applied when the event is completed without being canceled. OldValue holds the value of ToggleState at the time the state change was initiated. Canceled controls which value of ToggleState is applied when the event completes.  The default is false. Setting Cancel to true will prevent ToggleStateChanged from firing and will leave the ToggleState value as it was prior to the event.  In the example below the StateChangedEvent does not fire.

[C#] Handling ToggleStateChanging event Copy imageCopy
void radRadioButton3_ToggleStateChanging(object sender, StateChangingEventArgs args)
    args.Cancel = true;

void radRadioButton3_ToggleStateChanged(object sender, StateChangedEventArgs args)
    this.radRadioButton3.Text = args.ToggleState.ToString();
[VB.NET] Handling ToggleStateChanging event Copy imageCopy
Private Sub radRadioButton3_ToggleStateChanging(ByVal sender As Object, ByVal args As StateChangingEventArgs)
    args.Cancel = True
End Sub

Private Sub radRadioButton3_ToggleStateChanged(ByVal sender As Object, ByVal args As StateChangedEventArgs)
    radRadioButton3.Text = args.ToggleState.ToString()
End Sub

Due to the specifics of the simple data binding we have introduced the CheckChanging / CheckChanged events together with the CheckState property. These events and property provide the same functionality as the ToggleStateChanged, ToggleStateChanging and the ToggleState property, but give you the ability to simple data bind the control.