New to Telerik UI for WinForms? Download free 30-day trial

Handling RadCheckBox States

State Properties

The property which controls the state of RadCheckBox is called ToggleState. It is an enumeration and can be one of the following values: On, Off, or Indeterminate

Events

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

You can also handle ToggleStateChanging event. This event provides an opportunity to the toggle state change. The StateChangingEventArgs passed as a parameter to the event handler have a NewValue and OldValue ToggleState members and a boolean Cancel member. NewValue holds the value of the 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 value 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 ToggleStateChanged event does not fire.

void radCheckBox1_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
    MessageBox.Show(args.ToggleState.ToString());
}

Private Sub RadCheckBox1_ToggleStateChanged(ByVal sender As System.Object, ByVal args As Telerik.WinControls.UI.StateChangedEventArgs)
    MessageBox.Show(args.ToggleState.ToString())
End Sub

Due to the specifics of the simple data binding we have introduced the CheckStateChanging / CheckStateChanged 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.

In this article