TListBox lazarus / 10-Designer ---------------------------------------------------------------------- marko · 2005-05-17 16:47 How do I know which item is selected in TListBox, or which items are checked in TCheckListBox? Please help. ---------------------------------------------------------------------- matthijs · 2005-05-17 17:52 An example of finding the selected item(s) of a TListBox: Code: [Select] procedure TForm1.Button1Click(Sender: TObject); var   I: Integer; begin   if ListBox1.MultiSelect then begin     Memo1.Clear;     for I := 0 to pred(ListBox1.Items.Count) do begin       if ListBox1.Selected[I] then Memo1.Lines.Add(ListBox1.Items[I]);     end;   end else begin     if ListBox1.ItemIndex <> -1 then       ShowMessage('Selected item: ' + ListBox1.Items[ListBox1.ItemIndex])   end; end; ---------------------------------------------------------------------- matthijs · 2005-05-17 17:59 Owh, forgot about the TCheckListBox. That goes exactly the same: Code: [Select] procedure TForm1.Button2Click(Sender: TObject); var   I: Integer; begin   Memo1.Clear;   for I := 0 to pred(CheckListBox1.Items.Count) do begin     if CheckListBox1.Checked[I] then Memo1.Lines.Add(CheckListBox1.Items[I]);   end; end; ---------------------------------------------------------------------- marko · 2005-05-18 06:38 Thank you!