Question

I have a WinForm application with tekstbox controls that are connected to a ContextMenuStrip. If I rightclick on a textbox the context menu is (of course) opened. As far as I can see the ContextMenuStrip events don't give any info about the control on which the context menu was opened.

I can't use a work-around by looking at the focused control, as the rightclick doesn't give focus to the textbox (if it hasn't have focus before the rightclick).

So my question is: how can I determine the control on which the context menu was opened?

Était-ce utile?

La solution

Contextmenu has a SourceControl property which you should be able to use :)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top