Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-12

checklistbox: row checked, count row checked, enumerator and loop

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ugaciaka

Hi,

1. in checlistbox component existing property o function that show total row checked?

2. if possibile show if a row is checked if used enumerator (without using checlistbox.checked[i] in if statment)? I use enum := checlistbox.items.getenumerator and in a loop while enum.movenext but existing a property in enum.getcurrent for show if a item is checked?

tnx

Reply by email

Sven Barth
to ugaciaka
ugaciaka wrote 5 lines
Hi, 1. in checlistbox component existing property o function that show total row checked?

No, that's not possible. You need to do this manually.

2. if possibile show if a row is checked if used enumerator (without using checlistbox.checked[i] in if statment)? I use enum := checlistbox.items.getenumerator and in a loop while enum.movenext but existing a property in enum.getcurrent for show if a item is checked?

No, you can't do that either, because you need the index of the item.

The problem is (as well in your first question) that "Checked" is maintained inside the listbox control itself and not inside the item list.

As a side note: You do not need to use "GetEnumerator", "MoveNext" and "GetCurrent" directly. Just use a "for-in" loop:

var
   s: String;
begin
   for s in CheckListBox1.Items do begin
     // do something with "s"
   end;
end;

Regards,
Sven

Reply by email

Alexander Klenin
to Sven Barth
Sven Barth wrote 11 lines
On 19.12.2010 11:10, ugaciaka wrote: > 2. if ?possibile show if a ?row is checked if used enumerator (without > using checlistbox.checked[i] in if statment)? I use enum := > checlistbox.items.getenumerator and in a loop while enum.movenext but > existing a property in enum.getcurrent for show if a item is checked? No, you can't do that either, because you need the index of the item. The problem is (as well in your first question) that "Checked" is maintained inside the listbox control itself and not inside the item list.

Of course, this loop is frequently encountered in your application, you can write your own enumerator.

Alexander S. Klenin

Reply by email