Context Menu....
OK, so I have a context menu that contains two options - a TextBox and a (Submit) option...it pops up when a user right clicks a radio button on my form. I want the user to be able to enter a string in the textbox, click the (Submit) option, and have the string replace the current text of the radio button.
It works easy for one Radio Button, but I'd like to have this functionality available for several components. Aside from creating a separate context menue for each component (very time and space consuming), is there any way to refer to the object from which the context menu came from when writing the (Submit) option's code, so that I can do the same thing with only one Context Menu?
(hope that made sense...)
[726 byte] By [
East] at [2007-12-16]
Hi,
In your contextMenu Click event:
Me.ActiveControl.Text = toolStripTextBox1.Text
cheers,
Paul June A. Domag
I gave that a shot, but it still doesn't always work -- its possible to right click on an option that doesn't have the focus at the time, triggering the context menu. The option that has the focus is changed, even though it's not the one which triggered the context menu....
any other suggestions, plz?
The ContextMenuStrip has a SourceControl property that is supposed to return the control on which the menu was raised. The documentation is incomplete and the property is Nothing when I test it, so my guess is that it is incomplete at this stage. Until this property is properly implemented, I suggest you set a class-level variable using the sender in the MouseDown event handler.