Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: count disabled items in checkboxlist


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Oct 23, 2017 8:29 AM Last Post By: Lawson Lutchman
Lawson Lutchman

Posts: 31
Registered: 8/12/05
count disabled items in checkboxlist  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 22, 2017 7:23 AM
Hi Forum,

In my checklistbox i disable an item once selected. I need a count of all disabled items

I know

checklistbox1.itemenabled[0]:=true;

will disable ordinal 1, checklistbox1.count will give me total item count.

will try checklistbox1.count - checklistbox1.enabled...

Regards,

Edited by: Lawson Lutchman on Oct 22, 2017 7:25 AM
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: count disabled items in checkboxlist [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 23, 2017 7:56 AM   in response to: Lawson Lutchman in response to: Lawson Lutchman
Lawson Lutchman wrote:

Hi Forum,

In my checklistbox i disable an item once selected. I need a count of
all disabled items

I know

checklistbox1.itemenabled[0]:=true;

will disable ordinal 1, checklistbox1.count will give me total item
count.

will try checklistbox1.count - checklistbox1.enabled...
You mean to disable you set the property value to false eg.:

  checklistbox1.itemenabled[0]:=false;


To count the disabled items you should use the same property. For
example:

function DisabledItemsCount(PCheckListbox:  TCheckListBox): integer;
var i: integer;
begin
  result:=0;
  for i:=0 to PCheckListbox.Count-1 do
    if not PCheckListbox.ItemEnabled[i] then
      inc(result);
end;

You can now write ShowMessage(DisabledItemsCount(checklistbox1))

Lawson Lutchman

Posts: 31
Registered: 8/12/05
Re: count disabled items in checkboxlist [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 23, 2017 8:29 AM   in response to: Lajos Juhasz in response to: Lajos Juhasz
Thanks Lajos
Lajos Juhasz wrote:
Lawson Lutchman wrote:

Hi Forum,

In my checklistbox i disable an item once selected. I need a count of
all disabled items

I know

checklistbox1.itemenabled[0]:=true;

will disable ordinal 1, checklistbox1.count will give me total item
count.

will try checklistbox1.count - checklistbox1.enabled...
You mean to disable you set the property value to false eg.:

  checklistbox1.itemenabled[0]:=false;


To count the disabled items you should use the same property. For
example:

function DisabledItemsCount(PCheckListbox:  TCheckListBox): integer;
var i: integer;
begin
  result:=0;
  for i:=0 to PCheckListbox.Count-1 do
    if not PCheckListbox.ItemEnabled[i] then
      inc(result);
end;

You can now write ShowMessage(DisabledItemsCount(checklistbox1))

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02