프로그래밍

[vb.net] select listbox item on right click

프로세스 천국 2013. 10. 23. 14:33

Private Sub ListBox1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs ) Handles ListBox1.MouseUp
If e.Button = MouseButtons.Right Then
ListBox1.ClearSelected()
Dim n As Integer = Me.ListBox1.IndexFromPoint(e.X, e.Y)
If n <> ListBox.NoMatches Then
Me.ListBox1.SelectedIndex = n
End If
End If
End Sub