Board index » delphi » Number of checked items in a TCheckListBox

Number of checked items in a TCheckListBox

I want to get the number of checked items in my CheckListBox.
I have tried to use the SelCount property, but it always returns -1.
I some components, the MultiSelect property have to be true to make the
SelCount property work, but the CheckListBox doesn't have any MultiSelect
property.

How can I read the number of selected items at runtime?

Alan

 

Re:Number of checked items in a TCheckListBox


Quote
"Alan" <|> wrote:
>I want to get the number of checked items in my CheckListBox.
>I have tried to use the SelCount property, but it always returns -1.
>I some components, the MultiSelect property have to be true to make the
>SelCount property work, but the CheckListBox doesn't have any MultiSelect
>property.

>How can I read the number of selected items at runtime?

>Alan

The selecount property is the count of the items selected (highlighted) not the items that are checked.

check_count := 0;
for i := 0 to CheckListBox1.Items.Count - 1 do
   if(CheckListBox1.Checked[i]) then Inc(check_count);

Other Threads