...delete duplicate items in a stringlist?
Author: Simon Grossenbacher
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;
printed from
www.swissdelphicenter.ch
developers knowledge base