How to remove a selected item in a listbox by double-click

How can I remove a selected item in a list box by double-clicking?

If this requires a procedure please provide an example.

Thanks for your time
Stella PauleyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
The extra code in the MouseDown event will prevent the selected index from being deleted if you double click in the ListBox below the last item.  You also need to check if there is no selected item before attempting to delete it:

    Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
        ListBox1.SelectedIndex = ListBox1.IndexFromPoint(New Point(e.X, e.Y))
    End Sub

    Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
        If ListBox1.SelectedIndex <> -1 Then
        End If
    End Sub
Fahad MukhtarDistinguished EngineerCommented:
put this line in the Doubleclick Event of the Listbox:

All Courses

From novice to tech pro — start learning today.