2
I have 2 listview and a timer. This timer captures the records that exist with a certain comment and puts in the other listview. It turns out that he is repeating the records, I would like him to add only once the record, and checasse, if the record already exists in the other LISTVIEW, he ignores it. What am I doing wrong? Follow my code:
for I := 0 to Form1.LV1.Items.Count-1 do
begin
if Form1.LV1.Items[I].SubItems[5] = 'OK' then // confere se existe o comentário
begin
Form1.LV2.Visible := True;
L := Form1.LV2.Items.Add;
for J := 0 to Form1.LV2.Items.Count-1 do
if Form1.LV2.Items[J].SubItems[5] <> Form1.LV1.Items[I].SubItems[5] then // aqui tentei fazer não repetir (não deu certo).
Form1.LV2.Items.item[Form1.LV2.Items.count-1] := Form1.LV1.items.item[i];
end;
Any idea ?
it even worked in parts...what the problem ? He needs to add the record 1 time, and start doing these tests from the second, to see if there are repeats. Why ? Because if not already in the first record he will be talking that exists, understood ? For the first time I need to let it be added and then test if it is repeated. I don’t know if I understand.
– user7605
Before adding you check, if there is no, on the Else you enter. Would it be so, first check, doesn’t it exist? Adds.
– Filipe.Fonseca
I tried that @Filipe.Fonseca, I don’t know why it doesn’t work, I don’t know if it has to do with LISTVIEW being blank, I say the second listview before adding the ITEM, see the code: http://pastebin.com/waNQhJqs
– user7605
Quick question, @user7605 you are comparing items with subitens?
– Filipe.Fonseca
good question, actually I need to compare the 2 subitems, if it is equal, it does not add.
– user7605
Then I’ll need to change the Findlistviewitem routine to check everything. As soon as I have a little time I’ll do it for you.
– Filipe.Fonseca
it’s true @Filipe.Fonseca, the function is comparing a subitem to an item, had not even connected me in this!! Thanks friend just need this to finish the project.
– user7605
even could be compare only the items, do not need to compare the subitem. I just need to see if that record already exists or not in the other listview. What I need to change in this case ?
– user7605
You want items or subitens?
– Filipe.Fonseca
subitems mesmo.... changes a lot of things ?
– user7605
Well, I did both, Take a look at Edit, @user7605
– Filipe.Fonseca
I can use it like this? S := Form1.LV1.Items[i]. Subitems[3]; L4 := Verificalvsubitem(Form1.LV2, 3, S);
– user7605
worked out, thanks!!!
– user7605
Taking advantage of your kindness, you have a problem. If there are 5 records with the observation, it does not work, it only checks the first and adds in the other listview, the rest it does not add, because it will be ?
– user7605
Because the function only looks for a subitem, make a loop for or while and run it, so go get all the subitens
– Filipe.Fonseca
I did it, see, that’s not correct ? http://pastebin.com/qhRx5atm
– user7605