Board index » delphi » number of item selected in TCheckListBox

number of item selected in TCheckListBox

How do I find out how many items are selected in TCheckListBox other than
writing a loop.  The Selcount is always -1.  By the way, i'm using delphi
pro3, update 3.  Thanks.

if possible, please email me at w...@bigfoot.com

 

Re:number of item selected in TCheckListBox


Quote
> other than writing a loop

Write a loop, but do it once -- by creating a TCheckListBox descendant. (The
ability to easily create custom descendant components and install them into
the Delphi IDE is one of Delphi's principal features.) Here's the work, done
for you:

unit CheckListBox1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, CheckLst;

type
  TCheckListBox1 = class(TCheckListBox)
  protected
    function GetCheckedItemCount: Integer;
  public
    property CheckedItemCount: Integer read GetCheckedItemCount;
  end;

procedure Register;

implementation

function TCheckListBox1.GetCheckedItemCount: Integer;
var
  I: Integer;
begin
  Result := 0;
  for I := 0 to Items.Count - 1 do
    if Checked[I] then Inc(Result);
end;

procedure Register;
begin
  RegisterComponents('Samples', [TCheckListBox1]);
end;

end.

Re:number of item selected in TCheckListBox


I thought the there was a 3.02 and 4.03 but not a 3.03, did I miss
something?

Quote
On Tue, 22 Jun 1999 11:24:56 -0600, "wooi" <w...@bigfoot.com> wrote:
>How do I find out how many items are selected in TCheckListBox other than
>writing a loop.  The Selcount is always -1.  By the way, i'm using delphi
>pro3, update 3.  Thanks.

>if possible, please email me at w...@bigfoot.com

Dennis Powers
PC/POLL SYSTEMS
V 319-556-2323
F 319-556-0835
Den...@pcpoll.com

Other Threads