473,499 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MenuItem click question

Hi,

I have a context menu, which is used for each of 6 labels on my form. That
is, right-clicking any of the labels will bring up the same context menu.
Once the user clicks the menu, the clicked MenuItem fires an event:

menuItem1_Click(object sender, System.EventArgs e)

How can tell which of the 6 labels the menu is being clicked over?

Thanks,
Norvin
Nov 15 '05 #1
4 5112
100
Hi Norvin,
You can you use ContextMenu.Popup event and before the menu becomes visible
(before you move the mouse) you can check which label is under the mouse
cursor
this.GetChildAtPoint(this.PointToClient(Control.Mo usePos));
I assume that Popup event's handler is a memeber of the control class that
hosts the labels.
Now you can save the reference to the label and use it latter when
MenuItem's Click event gets fired.

HTH
B\rgds
100

"Norvin Laudon" <no************@molinospamenergy.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hi,

I have a context menu, which is used for each of 6 labels on my form. That
is, right-clicking any of the labels will bring up the same context menu.
Once the user clicks the menu, the clicked MenuItem fires an event:

menuItem1_Click(object sender, System.EventArgs e)

How can tell which of the 6 labels the menu is being clicked over?

Thanks,
Norvin

Nov 15 '05 #2
Norvin Laudon wrote:
Hi,

I have a context menu, which is used for each of 6 labels on my form. That
is, right-clicking any of the labels will bring up the same context menu.
Once the user clicks the menu, the clicked MenuItem fires an event:

menuItem1_Click(object sender, System.EventArgs e)

How can tell which of the 6 labels the menu is being clicked over?

Thanks,
Norvin


Norvin,

Have you tried looking at the object sender in your parameter?

hth,
Jonel
Nov 15 '05 #3
The sender is the MenuItem, which doesn't contain info about what control
the mouse was clicked on.

thanks,
Norvin

"Jonel Rienton" <csharp@nospam_here.core.com> wrote in message
news:3FC27165.7080801@nospam_here.core.com...

Norvin,

Have you tried looking at the object sender in your parameter?

hth,
Jonel

Nov 15 '05 #4
100,
"100" <10*@100.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi Norvin,
You can you use ContextMenu.Popup event and before the menu becomes visible (before you move the mouse) you can check which label is under the mouse
cursor
this.GetChildAtPoint(this.PointToClient(Control.Mo usePos));
I assume that Popup event's handler is a memeber of the control class that
hosts the labels.
Now you can save the reference to the label and use it latter when
MenuItem's Click event gets fired.

Thanks, that's the ticket...

Norvin


"Norvin Laudon" <no************@molinospamenergy.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hi,

I have a context menu, which is used for each of 6 labels on my form. That is, right-clicking any of the labels will bring up the same context menu. Once the user clicks the menu, the clicked MenuItem fires an event:

menuItem1_Click(object sender, System.EventArgs e)

How can tell which of the 6 labels the menu is being clicked over?

Thanks,
Norvin


Nov 15 '05 #5

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

Similar topics

9
3657
by: Rakesh | last post by:
Hi, I am able to obtain a MenuItem object's Name property @ design-time, but am not able to get the same @ run- time...why? And since MenuItem doesn't inherit from Control class, it's not...
6
6205
by: Claus Holm | last post by:
I'm trying to enable a menuitem in the parent form from a mdichild. Rather than making the menuitems public, I'd go for a public method in the parent form to do the change, but when I call the...
0
1368
by: Claire | last post by:
When I run the following code through on the first round, my sub-menu (branched off mnuOpenPorts menuitem) shows a nice list of ports. When it gets run through on the 2nd pass, the sub menu...
4
3482
by: Claire | last post by:
Sorry Ive added this twice (sortof) but if I'd added an addendum to the first one then this would probably have been ignored. This problem affects a ContextMenu attached to a NotifyIcon object. I...
2
1588
by: M Shafaat | last post by:
Hi, I want to develop an application with menus. I want to make only one event handler method which handles a whole group of menu items by firstly identifying which MenuItem sends the click event...
0
1318
by: ZH | last post by:
Hi There, I have an application that runs from the systray. When the user right clicks on the icon it shows the user a list of of menu items. That works without a problem. The problem is...
2
1314
by: genojoe | last post by:
Creating an enhanced menuItem with additional properties is easy to do. Is there also a way to enhance the menuItem by adding an event to it? I would like to have the MenuItem display a help...
9
2096
by: Sharon | last post by:
I have a Forms.ContextMenu with some Forms.MenuItem that has EventHandler for the Click event. The event handler function has the following signature: private void OnMenuItemClick(object...
2
2147
by: polocar | last post by:
Hi, I'm writing a program using Visual C# 2005 Professional Edition, and I was trying to assign multiple MainMenu objects (one by one, of course) to the same Form (let's suppose 2 MainMenu...
0
7134
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
7014
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6905
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
7395
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...
1
4921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.