473,396 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Determine right/left mouse click on Click/DoubleClick event

I need to determine whether the user used the right or left mouse
button to click an element on a form. AFAIK, there is no way to
determine this from the Click (or DoubleClick) event. I currently have
my form set up to have a MouseButtons instance that gets updated by the
MouseDown event, then the Click event checks the instance to see if it
was right or left. This works fine, but seems a very roundabout and
clumsy way to do something simple.

Is there a better way to do this?

Thanks in advance,
Chris

Nov 22 '05 #1
2 2761
Z
The MouseEventArgs argument received in MouseDown can be used to see which
button was clicked. Assuming you named this argument object mea, you can do
this

if (mea.Button == MouseButtons.Right) // it's the right button

"cmelnick" wrote:
I need to determine whether the user used the right or left mouse
button to click an element on a form. AFAIK, there is no way to
determine this from the Click (or DoubleClick) event. I currently have
my form set up to have a MouseButtons instance that gets updated by the
MouseDown event, then the Click event checks the instance to see if it
was right or left. This works fine, but seems a very roundabout and
clumsy way to do something simple.

Is there a better way to do this?

Thanks in advance,
Chris

Nov 22 '05 #2
I've been coming across this problem more than once. It's a pain, but I
haven't found a solution to it yet, except the roundabout way that you
have mentioned. Annoying, eh?

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: cmelnick | last post by:
I need to determine whether the user used the right or left mouse button to click an element on a form. AFAIK, there is no way to determine this from the Click (or DoubleClick) event. I currently...
3
by: mitsura | last post by:
Hi, I have included a small listing. The test program opens a panel and show a bitmap. What I want is to when the mouse is over the bitmap panel, I want to trap the left mouse click. The...
1
by: Sakharam Phapale | last post by:
Hi All, How to capture Mouse Single click and mouse double click event on Commnad Button. I am doing as follows. Private void Button1_MouseUp(Object sender,...
13
by: James Bond | last post by:
Hello. My 80+ year old father has recently decided to get his first computer. Due to his age (and I suspect lack of playing pong as a child like I did) he lacks the manual dexterity to use a mouse...
2
by: Dino M. Buljubasic | last post by:
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...
6
by: Sakharam Phapale | last post by:
Hi All, How to capture Mouse Single click and mouse double click event on Commnad Button. I am doing as follows. Private Sub Button1_MouseUp(ByVal sender As Object, ByVal e As...
2
by: Just Me | last post by:
Private Sub TreeViewFolders_DoubleClick(ByVal se... If TreeViewFolders.MouseButtons <> MouseButtons.Right Then If, as above, I try to check which mouse button caused the DoubleClick I get...
2
by: bretth | last post by:
In a VB.Net Windows Forms application, I have a user control that handles mouse events. Another section of code programmatically adds a label to the control. I would like label to ignore all...
1
by: akameswaran | last post by:
I have a list box, I'd like to generate a right click menu for items in the list box. The problem is unless I left click the item first, I can't figure out which item in the list I clicked over. ...
18
by: Shocky | last post by:
Hi there, I am trying to detect whether my IE6 users have pressed both right and left mouse buttons simultaneously in my Javascript code, by using: if(event.button==3) {alert("Both right and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.