"Martin" <x@y.com> schrieb:
I'm trying to correct the (imho) wrong behaviour of a listbox when the
user right-clicks on an item. I would like the selection to change when
this happens, just like when the user uses the left mouse button.
Most multi-item controls seem to have the hittest method, but in the
documentation of the listbox I can't find it.
\\\
Private Sub ListBox1_MouseUp( _
ByVal sender As Object, _
ByVal e As MouseEventArgs _:
) Handles ListBox1.MouseUp
If e.Button = MouseButtons.Right Then
Dim n As Integer = Me.ListBox1.IndexFromPoint(e.X, e.Y)
If n <> ListBox.NoMatches Then
Me.ListBox1.SelectedIndex = n
' Show context menu here using 'ContextMenu.Show'...
End If
End If
End Sub
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>