Notifications
Clear all

[Closed] Don't add duplicates to a dotnet listview – help please

Hi all

I have a button that when pressed, allows the user to select files from explorer and then the result is displayed in a dotnet listview. When the button is pressed again, more files can be added to the list.

So this works great:

theRange = #() 
for x=1 to lvItems.count do ( li = dotNetObject "System.Windows.Forms.ListViewItem" lvItems[x]; append theRange li )  
lv.Items.AddRange theRange


BUT, I don’t want any duplicates, so if I replace

append theRange li

with

appendifunique theRange li

it doesnt work. It still adds duplicates to the list if the user selects the same files. What am I doing wrong?

2 Replies

I can’t understand well your code.
Which value holds the new items to append? It seems you always append the same values.
You can also try to clear the list before adding range (lv.Items.Clear()).

hmmm…maybe its began when you collect the array.