Windows Forms' CheckBox CheckedChanged vs. CheckStateChanged
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
CheckedChanged fires when the Checked property (bool) changes between true and false. CheckStateChanged fires when the CheckState property (enum) changes between Unchecked, Checked, and Indeterminate. For standard two-state checkboxes, both events fire identically. The difference only matters when ThreeState = true — CheckStateChanged fires for all three transitions, while CheckedChanged only fires when the boolean Checked property actually changes (it does not fire when transitioning between Indeterminate and Checked since both have Checked = true).
The Two Properties
The relationship between them:
| CheckState | Checked |
Unchecked | false |
Checked | true |
Indeterminate | true |
Both Checked and Indeterminate map to Checked = true. This is why CheckedChanged does not fire when transitioning between these two states.
Two-State CheckBox (Default)
For two-state checkboxes, both events fire on every click with equivalent information.
Three-State CheckBox
The critical difference: transitioning from Checked to Indeterminate does not fire CheckedChanged because Checked remains true in both states.
Which Event to Use
Use CheckedChanged for Two-State Logic
Use CheckStateChanged for Three-State Logic
"Select All" Pattern
The _updating flag prevents infinite event loops when programmatically changing checkbox states.
Event Firing Order
Common Pitfalls
- Missing state transitions with CheckedChanged: In three-state mode,
CheckedChangeddoes not fire forChecked ↔ IndeterminatebecauseCheckedstaystrue. If you need all transitions, useCheckStateChanged. - Infinite event loops: Programmatically setting
CheckedorCheckStatefires the change event. If your event handler sets another checkbox, which fires its event, you get an infinite loop. Use a_updatingboolean flag to break the cycle. - Subscribing to both events: Subscribing to both
CheckedChangedandCheckStateChangedcauses double-handling in two-state mode (both fire on every click). Choose one based on whether you need two-state or three-state support. - Forgetting
ThreeState = true: WithoutThreeState = true, the checkbox only cycles betweenCheckedandUnchecked. SettingCheckState = Indeterminateprogrammatically works, but the user cannot reach it by clicking. - Initial state firing events: Setting
Checked = truein the constructor orLoadevent firesCheckedChanged. If your handler calls methods that depend on other controls being initialized, this causesNullReferenceException. Either subscribe to the event after initialization or guard against null references in the handler.
Summary
CheckedChangedfires whenChecked(bool) changes — use for simple on/off togglesCheckStateChangedfires whenCheckState(enum) changes — use for three-state checkboxes- In two-state mode, both events fire identically on every click
- In three-state mode,
CheckedChangedmisses theChecked ↔ Indeterminatetransition - Use
CheckStateChangedfor "Select All" patterns with indeterminate state - Use a boolean flag (
_updating) to prevent infinite event loops when programmatically setting checkbox state
Related reading
- Windows Forms vs. WPF
- Windows.Forms.Timer OR System.Threading.Timer
- Winforms Application.Exit vs Environment.Exit vs Form.Close
- WinForms Applications Where is console.writeline output rendered?
- Winforms TableLayoutPanel adding rows programmatically
- With block equivalent in C?
- With WPF, is there a method to detect method calls that are blocking GUI updates?
- Word wrap for a label in Windows Forms

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.