Mega Code Archive

 
Categories / Delphi / Strings
 

Delete duplicate items in a stringlist

Title: delete duplicate items in a stringlist? procedure TForm1.Button1Click(Sender: TObject); var sl: TStringList; begin sl := TStringList.Create; try with sl do begin // Duplicates does nothing // if the list is not sorted. Sorted := True; // Ignore attempts to add // duplicate strings to the list. Duplicates := dupIgnore; Add(Edit1.Text); end; Listbox1.Items.Assign(sl); finally sl.Free; end; end;