August 28th, 2012, 01:43 PM
Join Date: Jan 2006
Location: Carlsbad, CA
| how could I remove duplicates. |
It depends upon whether the items in your combobox must maintain their original order or whether they can be sorted.
If they can be sorted then all you need to do is something like this
tmpList := TStringList.Create;
tmpList.Sorted := True;
tmpList.Duplicates := duIgnore;
// Now add your items from file to tmpList
// Duplicates will be ignored
NOTE: Code above not tested or checked in any way; but the process is correct.
If you do NOT want the items sorted then you will either have to store the original order and re-arrange the items
or write your own algorithm for removing duplicates which, for efficiency, may depend
upon your knowledge of how duplicates may be separated in the file.