I have a txt
file with multiple records inside, I need something that at the time the function is to add to the ListView
these records, do not let me add repeated items. To do this, it could use a particular column and compare. Within the txt the delimiter I use is an @.
Code:
var
Linhas: TStringList;
Colunas: TStringList;
i,l: integer;
Item: TListItem;
begin
Linhas := TStringList.Create;
Colunas := TStringlist.Create;
Linhas.LoadFromFile('c:\clientes.txt');
for i := 0 to Linhas.Count-1 do
begin
Colunas.Text := StringReplace(Linhas[i],'@',Char(13)+Char(10),[rfReplaceAll]);
Item := Form1.LV.Items.Add;
l := l + 1;
Item.Caption := inttostr(l);
Item.SubItems.Add(Colunas[1]);
Item.SubItems.Add(Colunas[0]);
Item.SubItems.Add(Colunas[7]);
Item.SubItems.Add(Colunas[2]);
end;
end;