Products
Buttons Control for WinForms UI Tutorial
Add CheckBox buttons to C# Window Forms applications with the WinForms UI button component
Home > WinForms UI Controls > User Manual > CheckBox in C#

Check Box - C# WinForms UI Design

The Check Box of Windows Forms UI Button Component is designed to provide an interface element that can represent an on or off state using a check mark and could replace the Windows Forms Check Box control.
This Check Box control for Windows Forms supports three states management, including checked, unchecked, and undetermined. The ThreeState property specifies this. The ToggleState property determines the current state of the check mark and when the value of it is false, the ToggleState can be On or Off. Otherwise the value of On, Off, or Indeterminate are available.
The Check Box Control for Windows Forms is able to add robust data binding and more extended UI design options like image, multi-line text, animations, shapes, and more. When creating the Check Box, a few themes are included for the check box design.

Related Button UI for C# Windows Forms Applications

How to Customize the Check Box States

In the Check Box control for WinForms, the ToggleState property determines the state of the Check Box and the state of the check box can be each one of the three: On, Off, or Indeterminate.

Events to Change the ToggleState property

To toggle the button, we can use the ToggleStateChanged event of CheckBox and pass a StateChangedEventArgs parameter to the event handler. The following is the C# Code for ToggleStateChanged:

void checkBox1_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
MessageBox.Show(args.ToggleState.ToString());
}
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.

C# Code for ToggleStateChange


void checkBox1_ToggleStateChanging(object sender, StateChangingEventArgs args)
{
args.Cancel = true;
}
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