Search code examples
delphidelphi-2010vcl

Uncheck all checkboxes in a TCheckListBox


I want the user to be able to press a button to reset a TCheckListBox to it's initial state (having no boxes checked).

See images below of an example of what I want to happen after clicking the button:

Multiple checked boxes in a TCheckBoxList

Changed to:

No boxes are checked

How would I go about doing this? I know there would probably be a loop involved, but I'm unsure where to start. Thanks for the help in advance.


Solution

  • There is nice method - look at official help.

    If we open TCheckListBox help page, choose Methods and filter off "inherited" ones, we'll see CheckAll method

    CheckListBox1.CheckAll(cbUnchecked);