ListView Right Click Event

  • Thread starter Thread starter Dino M. Buljubasic
  • Start date Start date
D

Dino M. Buljubasic

I have a list view with couple of items in it.
When I left click on an item, a form opens displaying that item's
properties. So that works fine.

However, accidentally I found out that when I right click on my list view
item, the click event gets generated twice and causes my application to
crash because sender.parent is nothing.

How can I restrict my list view to react only on left click or behave the
same way even when right clicked. Either one will be fine for me.

Regards, Dino
 
Dino, if you want to cancel the right click of the mouse (in the mouse down
event) check if e.Button = MouseButtons.Right and just ignore it. This
would necessitate changing where your code fired from (MouseDown vs. Click)
..

On the other hand.... If sender is Nothing Then Exit Sub
 
* "William Ryan said:
Dino, if you want to cancel the right click of the mouse (in the mouse down
event) check if e.Button = MouseButtons.Right and just ignore it. This
would necessitate changing where your code fired from (MouseDown vs. Click)

Typically, 'MouseUp' is used in this case instead of 'MouseDown'.
 
Back
Top