Loop thru all the items in the listview with index for tracking the item against the loop variable. compare the values of each item and delete which ever match the criteria. when deletion occurs the indices of the items following the deleted item will change. hence keep track of the last index.
If still problem persists then i will try to help u with some sample code.
Dim iVal As Integer
Dim lCount As Integer
lCount = li.ListItems.Count
For iVal = 1 To lCount
If iVal > lCount Then Exit For
'If u want to compare to the First Column
If Trim(li.ListItems(iVal).Text) = Trim(Text1.Text) Then
iVal = iVal - 1
lCount = lCount - 1
''If u want to compare to the other Column use SubItems
''SubItems(1) is 2nd col, SubItems(2) is 3rd col and so on...
' If Trim(li.ListItems(iVal).SubItems(1)) = Trim(Text1.Text) Then
' li.ListItems.Remove (iVal)
' iVal = iVal - 1
' lCount = lCount - 1
' End If
also while comparing if u don't want it to be case sensitive use the UCASE() function
If UCase(Trim(li.ListItems(iVal).Text)) = UCase(Trim(Text1.Text)) Then
if you just remove the data in the listview, and when your listview was not bound in the database, everytime you load the form the data you remove will back again since you dont remove it in the database... how about delete it from the database then reload the loading of your listview.
The Logic for the removal of the related records in the database can be written just before the Remove event of the ListView. After all matched Items are done, U will have the database updated as well as the ListView and I think there is no need to Reload the ListView, which involved again querying the DB. Alternatively it can be done to re-confirm if the records are really deleted from the DB or not.
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim a As String
If KeyCode = vbKeyDelete Then
If listview1.SelectedItem = True Then
a = MsgBox("Are you sure you want to delete?", vbInformation + vbYesNo, "REQUESTING CONFIRMATION")
If vbYes Then
I Developed application in C# with crystal reports and created setup file in third party (Advance) Installer.When i installed my application on client system application is working but ...