I can write code to prevent a duplicate item in a listview from being added but I want to prevent duplicate subitems from being placed in a listview.
Here is what I have and hopefully someone can modify it for me.
Dim lstAttItem As ListViewItem = New ListViewItem(Trim(txtName.Text))
Dim lvDup As ListViewItem
For Each lvDup In lstMenu.Items
If UCase(Trim(lvDup.Text)) = UCase(Trim(txtName.Text)) Then
MsgBox("Duplicate Values are not permitted. Please fix.", MsgBoxStyle.Information, "ListView Error")
lstAttItem.SubItems.Add(Trim(txtCode1.Text)) 'need code to prevent the same subitem being added to this column
lstAttItem.SubItems.Add(Trim(txtCode2.Text)) 'need code to prevent the same subitem being added to this column
'note this is a 3 column listview. The same item could exist as a subitem in another column. A duplicate subitem could exist in column 2 and 3 it just could not exist twice in the same column.
John, J, 123
J, 123, John
Tom, J, 678
Tim, P, 123
Rows 1,2 and 5 could be added to listview. Row's 3 and 4 have conflicts thus should be rejected.
Any help appreciated.