MenuItem click question

N

Norvin Laudon

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
 
J

Jonel Rienton

Norvin said:
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
 
1

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.MousePos));
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
 
N

Norvin Laudon

The sender is the MenuItem, which doesn't contain info about what control
the mouse was clicked on.

thanks,
Norvin
 
N

Norvin Laudon

100,


100 said:
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.MousePos));
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top