Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete strings from TStringList

I have a List Box or a List View with items. And I have a String List with the same items (strings) as the List Box/List View. I want to delete all selected items in the List Box/List View from the String List.

How to do?

for i:=0 to ListBox.Count-1 do
  if ListBox.Selected[i] then
    StringList1.Delete(i); // I cannot know exactly an index, other strings move up
like image 737
maxfax Avatar asked Jul 25 '11 20:07

maxfax


1 Answers

for i := ListBox.Count - 1 downto 0 do
  if ListBox.Selected[i] then
    StringList1.Delete(i);
like image 96
Andreas Rejbrand Avatar answered Sep 18 '22 00:09

Andreas Rejbrand