Get MultiSelect content from Listbox and play in a Memo on the same line

2

I need to play content with one or more selections from TListbox to TMemo .

Turned on MultiSelect to True,

I'm using:

ListBox.Items[ListBox.ItemIndex] 

Only with a selection it list normal, I need it to list if I check your lines display: selection1, selection2

Currently only displays selection1 regardless of how many I choose

    
asked by anonymous 22.12.2015 / 15:24

1 answer

2

You should make a loop and scroll through the entire list by looking for the selected values, going from 1 to 1.

procedure TForm1.Button1Click(Sender: TObject);
var
  i : Integer;
begin
  for i := 0 to ListBox1.Items.Count -1 do
  begin
    if (ListBox1.Selected[i]) then
    begin
      if (Memo1.Text = '') then
        Memo1.Text := ListBox1.Items[i]
      else
        Memo1.Text := Memo1.Text + ', ' + ListBox1.Items[i];
    end;
  end;
end;

I await Feedback.

    
22.12.2015 / 16:58