MenuItem click question

  • Thread starter Thread starter Norvin Laudon
  • Start date Start date
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
 
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
 
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
 
The sender is the MenuItem, which doesn't contain info about what control
the mouse was clicked on.

thanks,
Norvin
 
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
 
Back
Top