Here is the code for deleting the data from the ListView. Using this code you can delete the whole row of the data. I have also included message box in the coding so that it will ask for the confirmation. Here is the code for deletion of data :
Code:
Sub BtnDeleteClick(sender As Object, e As EventArgs)
Dim selItem As New ListViewItem
Dim result As DialogResult
result = MessageBox.Show("Are you sure you want to delete the selected item(s)?", _
"Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = DialogResult.No Then
MessageBox.Show("Delete action has been cancelled.", "Delete Cancelled", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
For Each selItem In listViewRec.SelectedItems
selItem.Remove()
Next
End If
End Sub
If you select No after the confirmation asked, then the data will not get deleted. Clicking on Yes will delete the data. Hope that this code help you.
Bookmarks