0

How do i control entry of a record to a listview if it creates duplication,not to a database of course.It checks all the items in the listview including the subitems and then notifies the user that there is a reocrd in the listview if there exists,otherwise recorded I still can't the right code.

Can you help me out please?

1 Answer 1

1

Either bind to a collection that does not allow duplicates (i.e. HashSet) or loop through the entire list of items before adding to see if the item already exists. I recommend the HashSet route, as it will return False if you try to add a duplicate item to the collection, thus your code for adding is simplified to this:

If hashSet.Add(yourNewValue) Then
    ' Succesfully added
Else
    ' Value already exists, add did not happen
End If
Sign up to request clarification or add additional context in comments.

1 Comment

And, it's faster than looping through the entire list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.