Does anyone have a quicker and better way to remove duplicates from a listview? I am currently doing it like this: I sort the items alphabetically, and then it checks the item below and compares it with the one above.
This is time consuming though.. When I enter 20.000 records into an excel sheet, and remove duplicates it takes a few miliseconds, but with this code below it takes hours to check 20.000 items in vb.net. Does anyone know of a faster method?
Dim max As Integer = ListView2.Items.Count
Dim i As Integer = 0
For Each item As ListViewItem In ListView2.Items
If i = max Then
Exit For
End If
If i > 0 Then
If item.Text = ListView2.Items(i - 1).Text Then
max -= 1
item.Remove()
i -= 1
End If
End If
i += 1
Label4.Text = "Total domains: " & ListView2.Items.Count
Next