$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
Buttons Control for WinForms UI Tutorial
Toggle button design for C# Window Forms applications with the WinForms UI button component
Home > WinForms UI Controls > User Manual > Toggle Button in C#

Toggle Button - C# WinForms UI Design

The Toggle Button for WinForms is designed to manage states on your .NET Windows Forms. It has similar functionality of the check box. However, the Toggle button control provides a different visual effect and more flexible stylish design than the standard check box button. This Toggle button control add state management similar to that of the Check Box with the addition of a special toggle state changing event which provides extra control over its state.

Related Button UI for C# Windows Forms Applications

How to Manage the Toggle Button States

Toggle State Properties

The Toggle State property is used to set the state of Toggle Button.

How to Manipulate Events

.NET Forms developers could manipulate the Toggle State Changed event to control the Toggle Button to change when users toggle the button. The event handler will pass the parameter of State Changed Event Args that includes a Toggle State member.

void ToggleButton1_ToggleStateChanged(object sender, StateChangedEventArgs args)
It is also possible to operate the event of Toggle State Change to cancel the change of the toggle states here. The following are some properties for manipulating the event of Toggle State Change:

Properties Available:

  • StateChangEventArgs will be passed to the event handler via a parameter
  • New Value property, included under the StateChangEventArgs, controls the value of the Toggle State that will be applied when the event is completed
  • Old Value property, included under the StateChangEventArgs, specify the value of Toggle State when the change of the toggle state was initiated
  • Cancel property, a Boolean value and included under the StateChangEventArgs, determines the value of Toggle State is applied when the event being completed. When the value of this property is true, it will prevent the property of Toggle State Changed from initializing and will leave the value of Toggle State as it was.
The following is a sample C# code for manipulating the Toggle State Change event. The C# code will let a Toggle Button to toggle only if the value of a second Toggle Button is set to off. The toggle will be canceled if developers set both the value of the second button toggle state and the value of the New Value as On. The event of Toggle State Changed will only triggers and changes the property of Text when the value of Toggle State Change is not Cancel.

private void ToggleButton2_ToggleStateChanging(object sender,
WinControls.UI.StateChangingEventArgs args)
bool attemptingOn = args.NewValue ==
args.Cancel = true;

private void ToggleButton2_ToggleStateChanged(object sender,
WinControls.UI.StateChangedEventArgs args)
ToggleButton1.Text = args.ToggleState.ToString();
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls