1. Computing
in Delphi TIPS :: Many Delphi controls like TListBox, TComboBox and TMemo, for example, expose a property which is of the TStrings type: Items for TListBox, Lines for TMemo. When you fill in a string list with string items you might end up with a list holding duplicate strings - more than one item with the 'same' string value.

Read the full article to learn how to Remove Duplicate Items in Delphi's TStringList

Related:

Comments
March 9, 2009 at 1:29 pm
(1) Jens Borrisholt says:

Just for the record this could also be done with a class helper (if you are useing Delphi 2007 or newer) :

type
TStringListHelper = class helper for TStringList
public
procedure RemoveDuplicates;
end;

{ TStringListHelper }

procedure TStringListHelper.RemoveDuplicates;
var
Buffer: TStringList;
cnt: Integer;
begin
Sort;
Buffer := TStringList.Create;
try
Buffer.Sorted := True;
Buffer.Duplicates := dupIgnore;
Buffer.BeginUpdate;
for cnt := 0 to Count – 1 do
Buffer.Add(Get(cnt));
Buffer.EndUpdate;
Assign(Buffer) ;
finally
FreeAndNil(buffer) ;
end;
end;

Jens B

April 11, 2011 at 11:37 am
(2) Mihaela says:

aStringList.Duplicates := dupIgnore

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

©2014 About.com. All rights reserved.