Get the control that fired the context menu

R

Robert Mago

I have a scenario where a user can click on a textbox, a context menu is
displayed and he can select a particular text from the list. Then, that text
will be appended to the textbox.

Thus i have several textboxes, that share the same context menu since the
text is common, and all the items in the context menu share the same click
event since they perform the same action, its just the text to append that
varies.

My query is from that event, how would i find out which textbox was used?
 
A

Alberto Poblacion

Robert Mago said:
I have a scenario where a user can click on a textbox, a context menu is
displayed and he can select a particular text from the list. Then, that
text will be appended to the textbox.

Thus i have several textboxes, that share the same context menu since the
text is common, and all the items in the context menu share the same click
event since they perform the same action, its just the text to append that
varies.

My query is from that event, how would i find out which textbox was used?


In the event, the "sender" argument will give you the ContextMenu that
triggered the event. Now that you have the contextmenu, its property
"SourceControl" will give you the control that is displaying the
contextmenu.
 

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