Customize your ListView to have an event handler for the KeyDown event. Then verify that the key was pressed by the delete key. Then use SelectedItems to see which items are selected and delete them. Remember to do it from the bottom up, because the collection of SelectedItems will be constantly changing.
private void listView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Delete)
{
for (int i = listView1.SelectedItems.Count - 1; i >= 0; i--)
{
ListViewItem li = listView1.SelectedItems[i];
listView1.Items.Remove(li);
}
}
}
source
share