Can you tell what object was under the mouse when right clicking to open the RadContextMenu ?

1 Answer 44 Views
ContextMenu
Troy
Top achievements
Rank 3
Bronze
Iron
Iron
Troy asked on 02 Jun 2023, 01:00 AM

Basically, I have a function that deals with various items, based on what the user clicked on.

So when they right click on say a label and I open my context menu, how do I figure out what label (object) it was that they clicked on?

I could do an event for every label, but that seems... bad. 

I attempted to use the event DropDownOpening to see if I could access the sender for the right click to open the menu, but haven't had any luck there.

Troy
Top achievements
Rank 3
Bronze
Iron
Iron
commented on 02 Jun 2023, 01:45 AM

I attempted this: Dim a As RadLabelElement = sender

 

And that looks like its right, meaning it has the correct Text property of the label I clicked on.  But what I really need is the .tag property off of it, and it is set to Nothing.  Although I can directly look at the label.tag and its correct. 

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 06 Jun 2023, 07:17 AM

Hi Troy,

Thank you for your interest in our RadContextMenu control.

I am assuming that the Tag property of the control is set in your application. You are right that the sender in the DropDownOpening event handler of the RadContextMenu will be the element of the control: RadLabelElement if the control is RadLabel, for example. In this case, you can consider setting the Tag property of the element instead. 

Me.RadLabel1.LabelElement.Tag = "BBBB"

Could this be an option for you?

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Troy
Top achievements
Rank 3
Bronze
Iron
Iron
commented on 06 Jun 2023, 01:57 PM

Hey Dino, thanks for the reply.

Unfortunately that won't work for me, as the tag property is already in use for other things.  Any other suggestions?

Troy
Top achievements
Rank 3
Bronze
Iron
Iron
commented on 06 Jun 2023, 02:00 PM

Wait... I see what you're saying.  I'll give it as shot, but I don't think that is going to work. But... maybe.  =)

Thanks!

Dinko | Tech Support Engineer
Telerik team
commented on 07 Jun 2023, 07:48 AM

The control and its element have Tag property. My point was setting the Tag property of the element initially to store your information. You can share if this approach will work for you.
Tags
ContextMenu
Asked by
Troy
Top achievements
Rank 3
Bronze
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or