Get object that called context menu

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

Hello,

I have a single ConextMenu that is used for dozens of labels. When the user
right-clicks the label, they select a menu item, and that label's text and
tag should be added to a ListBox.

How can I reference the label that initially called the context menu to
popup? I know that I could get the X, Y coordinates of the click, but is
there a more precise way to do this?

Thank you,

Eric
 
Eric said:
Hello,

I have a single ConextMenu that is used for dozens of labels. When
the user right-clicks the label, they select a menu item, and that
label's text and tag should be added to a ListBox.

How can I reference the label that initially called the context menu
to popup? I know that I could get the X, Y coordinates of the click,
but is there a more precise way to do this?

Thank you,

Eric

I could be completely off-track, since I am a bit of a novice...

But couldn't you use the *sender* argument to grab the label's identity on
a mouseup/down event? Or is that not how you access your ContextMenu?
 
I could be completely off-track, since I am a bit of a novice...
But couldn't you use the *sender* argument to grab the label's identity on
a mouseup/down event? Or is that not how you access your ContextMenu?

Thank you for the reply, Confessor. The sender argument is of type
MenuItem. Mick's answer (ContextMenu.SourceControl) is correct.

Eric
 
Thank you, Mick. Just what I was looking for. (I don't know how I missed
that on MSDN!)

Eric

"Mick Doherty"
 

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

Back
Top