Delphi TStringList not allowing duplicates

Posted by BeckyR:

How do I use the duplicates property to raise an exception when a duplicate string is added to a Delphi stringlist?
This is some of the code I have started with but no exception is being raised so I am sure I am missing something. Thanks.

for iTemp := 0 to frmData.sgClasses.Rowcount - 1 do
begin
  try
    slGeneratedTemp.Add(frmData.sgClasses.Cells[11,iTemp]);
  except on EStringListError do showmessage('duplicate scan codes');
  end;
end; 
 

Related Articles and Replies:


DelphiLand Discussion Forum Delphi Tutorials