how can I use Alt+Del to Delete listview item ...
Now I just select the row and press del key delete the item, But I want to delete item by press alt+del key. How it is possible Please help me....

What I have tried:

 Private Sub ListView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListView1.KeyDown

            If e.KeyCode = Keys.Delete Then

                Dim i As ListViewItem
                i = ListView1.SelectedItems(0)
                i.Remove()

            End If

        End Sub

Are you talking about a ListView, a container of images? Or perhaps are you refering to a listbox filled with items?

Dim i As ListViewItem

  i = ListView1.Items.Add(txtitemsl.Text)
        i.SubItems.Add(cmbitemNM.Text)
        i.SubItems.Add(txtitmnm.Text)
        i.SubItems.Add(txtitmdes.Text)
        i.SubItems.Add(txtitemqty.Text)
        i.SubItems.Add(txtitemmrp.Text)
        i.SubItems.Add(txtitemrate.Text)
        i.SubItems.Add(txtitemdis.Text)
        i.SubItems.Add(txtitemvat.Text)
        i.SubItems.Add(txtitemtaxamt.Text)
        i.SubItems.Add(txtnettax.Text)
        i.SubItems.Add(txtitemamt.Text)

I would code this way:

    Public Sub listView1_KeyDown(sender As Object, e As System.Windows.Input.KeyEventArgs) Handles ListView1.KeyDown
        If e.Key = Key.System AndAlso _
        e.SystemKey = Key.Delete Then
            If ListView1.SelectedItems.Count Then
                Dim item As ListViewItem = ListView1.SelectedItems(0)
                ListView1.Items.Remove(item)
                e.Handled = True
            End If
        End If
    End Sub

Now showing some error

Please post that code as of the start of the Sub to the end of that sub End Sub so that we can see what's wrong, but I think your code is outside the Sub that why you are getting those errors but that can be confirmed after you have posted the code as I stated above so that we can see what went wrong or what is wrong with your code.

Sorry, I thought your code was for WPF. So, it should be:

    Public Sub listView1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles ListView1.KeyDown
        If e.Modifiers = Keys.Alt AndAlso _
        e.KeyCode = Keys.Delete Then
            If ListView1.SelectedItems.Count Then
                Dim item As ListViewItem = ListView1.SelectedItems(0)
                ListView1.Items.Remove(item)
                e.Handled = True
            End If
        End If
    End Sub

Hay!
Thanks, many many thanks. It is work fine thank you
You are Great.

Thank you for your confidence.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.