Thema: Delphi Listview checkbox

Einzelnen Beitrag anzeigen

s-off
(Gast)

n/a Beiträge
 
#7

Re: Listview checkbox

  Alt 22. Aug 2007, 14:16
Try this:

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
   i: Integer;
   iChecked: Integer;
begin
   iChecked := 0;

   for i := 0 to ListView1.Items.Count - 1 do begin
      if ListView1.Items[i].Checked then
         Inc(iChecked);
   end;

   if iChecked > 1 then begin
      if iChecked < ListView1.Items.Count then
         Form1.Caption := 'some items are checked'
      else
         Form1.Caption := 'All items are checked';
   end
   else begin
      case iChecked of
         0: Form1.Caption := 'No item is checked';
         1: Form1.Caption := 'One item is checked';
      end;
   end;
end;
Edit:
In addition you could store the indexes (Checked = True) in an array or similar.
  Mit Zitat antworten Zitat