Reputation:
I have a simple question. How to get the count of checked item in CheckBoxListBox without using a loop?
Upvotes: 3
Views: 3154
Reputation: 510
you can use a function like this.
function GetCheckedCount(CH:TCheckListBox):Integer;
var I:Integer;
begin
Result := 0;
for i := 0 to ch.Items.Count - 1 do
if ch.Checked[i] then inc(result);
end;
Also, SelCount is the number of "selected" items when MultiSelect is true ,Not number of "Checked" items
Upvotes: 1
Reputation: 1178
In Delphi you can [*] do the following:
TCustomMultiSelectListControl(TheBox).MultiSelect := True;
and then SelCount works:
CountOfCheckedItems := TheBox.SelCount;
Isn't the equivalent possible in C++?
[*] Although it causes other problems.
Upvotes: 0
Reputation: 597941
TCheckListBox
does not provide the option that you are looking for. A loop through its Checked[]
property is required.
If you were using Delphi, you could create a class helper to hide that loop. But class helpers are not available in C++.
Upvotes: 6