ClassRadToggleButton
Represents a RadToggleButton. A ToggleButton may have the following states: On, Off, and Indeterminate. The button may have only the first two states if the IsThreeState property is set to false.
The RadToggleButton class is a simple wrapper for the RadToggleButtonElement. All UI and logic functionality is implemented in the RadToggleButtonElement class. The latter can be nested in other telerik controls. RadToggleButton acts to transfer events to and from the its corresponding RadToggleButtonElement instance.
Definition
Namespace:Telerik.WinControls.UI
Assembly:Telerik.WinControls.UI.dll
Syntax:
[DefaultBindingProperty("Text")]
public class RadToggleButton : RadButtonBase, IDropTarget, ISynchronizeInvoke, IWin32Window, IBindableComponent, IComponent, IDisposable, INotifyPropertyChanged, ISupportInitializeNotification, ISupportInitialize, IComponentTreeHandler, ILayoutHandler, IAnalyticsProvider, ISupportRootUIAutomation
Inheritance: objectMarshalByRefObjectComponentControlScrollableControlRadControlRadButtonBaseRadToggleButton
Derived Classes:
Implements:
Inherited Members
Constructors
RadToggleButton()
Initializes a new instance of the RadToggleButton class. Creates a toggle button with default settings and unchecked state.
Declaration
public RadToggleButton()
Properties
ButtonElement
Gets the RadToggleButtonElement that represents the visual element of this toggle button control. This element contains the visual styling and behavior logic for the toggle button.
Declaration
[Browsable(false)]
public RadToggleButtonElement ButtonElement { get; }
Property Value
A RadToggleButtonElement that represents the button's visual element.
CheckState
Gets or sets the check state of the toggle button using CheckState enumeration. Supports three states: Checked, Unchecked, and Indeterminate (when IsThreeState is true).
Declaration
[Browsable(true)]
[Bindable(true)]
public CheckState CheckState { get; set; }
Property Value
One of the CheckState enumeration values.
DefaultSize
Gets the default size for the toggle button control.
Declaration
protected override Size DefaultSize { get; }
Property Value
Overrides
EnableUIAutomation
Gets or sets a value indicating whether UI Automation support is enabled for this toggle button. Enables accessibility features for screen readers and other assistive technologies.
Declaration
public override bool EnableUIAutomation { get; set; }
Property Value
true if UI Automation is enabled; otherwise, false.
Overrides
Implements
IsChecked
Gets or sets a value indicating whether the toggle button is in the checked state. This is a simplified boolean representation of the button's toggle state.
Declaration
[Browsable(true)]
[Bindable(true)]
public virtual bool IsChecked { get; set; }
Property Value
true if the button is checked; otherwise, false.
IsThreeState
Gets or sets a value indicating whether the toggle button supports three states. When true, the button can have Checked, Unchecked, and Indeterminate states.
Declaration
[Browsable(true)]
[Bindable(true)]
public bool IsThreeState { get; set; }
Property Value
true if the button supports three states; otherwise, false.
ReadOnly
Gets or sets a value indicating whether the toggle button is in read-only mode. When read-only, the button cannot be toggled by user interaction but can still be changed programmatically.
Declaration
[Browsable(true)]
public bool ReadOnly { get; set; }
Property Value
true if the button is read-only; otherwise, false.
ToggleState
Gets or sets the toggle state of the button using the ToggleState enumeration. This property provides more granular control over the button's state than IsChecked.
Declaration
[Browsable(true)]
[Bindable(true)]
public ToggleState ToggleState { get; set; }
Property Value
One of the ToggleState enumeration values (Off, On, Indeterminate).
Methods
ButtonElement_ToggleStateChanged(object, StateChangedEventArgs)
Handles the ToggleStateChanged event from the underlying button element and forwards it to the control's event.
Declaration
protected virtual void ButtonElement_ToggleStateChanged(object sender, StateChangedEventArgs args)
Parameters
sender
The source of the event.
args
A StateChangedEventArgs that contains the event data.
ButtonElement_ToggleStateChanging(object, StateChangingEventArgs)
Handles the ToggleStateChanging event from the underlying button element and forwards it to the control's event.
Declaration
protected virtual void ButtonElement_ToggleStateChanging(object sender, StateChangingEventArgs args)
Parameters
sender
The source of the event.
args
A StateChangingEventArgs that contains the event data.
CreateAccessibilityInstance()
Creates an accessibility instance for the toggle button to support assistive technologies.
Declaration
protected override AccessibleObject CreateAccessibilityInstance()
Returns
An AccessibleObject that provides accessibility support for the toggle button.
Overrides
CreateButtonElement()
Create main button element that is specific for RadToggleButton.
Declaration
protected override RadButtonElement CreateButtonElement()
Returns
The element that encapsulates the functionality of RadToggleButton
Overrides
CreateChildItems(RadElement)
Creates the child items for the toggle button and establishes event handlers with the underlying button element.
Declaration
protected override void CreateChildItems(RadElement parent)
Parameters
parent
The parent RadElement that will contain the child items.
Overrides
InitializeUIAutomationProvider()
Initializes and returns the UI Automation provider for this toggle button control.
Declaration
protected virtual IRadRawElementProviderFragmentRoot InitializeUIAutomationProvider()
Returns
IRadRawElementProviderFragmentRoot
An IRadRawElementProviderFragmentRoot that provides UI Automation support.
OnCheckStateChanged(EventArgs)
Raises the CheckStateChanged event.
OnCheckStateChanging(CheckStateChangingEventArgs)
Raises the CheckStateChanging event.
Declaration
protected virtual void OnCheckStateChanging(CheckStateChangingEventArgs e)
Parameters
e
A CheckStateChangingEventArgs that contains the event data.
OnToggleChanged(EventArgs)
Called when the toggle state changes to provide a common event handling point for derived classes.
OnToggleStateChanged(EventArgs)
Raises the StateChanged event.
OnToggleStateChanging(StateChangingEventArgs)
Raises the StateChanging event.
Declaration
protected virtual void OnToggleStateChanging(StateChangingEventArgs e)
Parameters
e
A StateChangingEventArgs that contains the event data.
ResetBackColorThemeOverrides()
Resets the background color theme overrides to their default values.
Declaration
protected override void ResetBackColorThemeOverrides()
Overrides
ResetForeColorThemeOverrides()
Resets the forecolor theme overrides to their default values.
Declaration
protected override void ResetForeColorThemeOverrides()
Overrides
SetBackColorThemeOverrides()
Sets theme overrides for the background color property across all visual states of the button element.
Declaration
protected override void SetBackColorThemeOverrides()
Overrides
SetForeColorThemeOverrides()
Sets theme overrides for the forecolor property across all visual states of the button element.
Declaration
protected override void SetForeColorThemeOverrides()
Overrides
WndProc(ref Message)
Processes Windows messages and handles UI Automation and control lifecycle messages.
res_CheckStateChanged(object, EventArgs)
Handles the CheckStateChanged event from the underlying button element and forwards it to the control's event.
res_CheckStateChanging(object, CheckStateChangingEventArgs)
Handles the CheckStateChanging event from the underlying button element and forwards it to the control's event.
Declaration
protected virtual void res_CheckStateChanging(object sender, CheckStateChangingEventArgs args)
Parameters
sender
The source of the event.
args
A CheckStateChangingEventArgs that contains the event data.
res_PropertyChanged(object, PropertyChangedEventArgs)
Handles property changes from the underlying button element, specifically for the IsChecked property.
Declaration
protected virtual void res_PropertyChanged(object sender, PropertyChangedEventArgs e)
Parameters
sender
The source of the event.
e
A PropertyChangedEventArgs that contains the event data.
Events
CheckStateChanged
Occurs after the check state has changed. This event is fired after the CheckState property has been updated.
Declaration
[Browsable(true)]
public event EventHandler CheckStateChanged
Event Value
CheckStateChanging
Occurs before the check state changes, providing an opportunity to cancel the change. Event handlers can validate the new state and cancel if necessary.
Declaration
[Browsable(true)]
public event CheckStateChangingEventHandler CheckStateChanging
Event Value
ToggleStateChanged
Occurs after the toggle state has changed. This event is fired after the ToggleState property has been updated to its new value.
Declaration
[Browsable(true)]
public event StateChangedEventHandler ToggleStateChanged
Event Value
ToggleStateChanging
Occurs before the toggle state changes, allowing the change to be cancelled. Event handlers can set the Cancel property of the event args to prevent the state change.
Declaration
[Browsable(true)]
public event StateChangingEventHandler ToggleStateChanging
Event Value