From: Peter Duniho on
Helmut Giese wrote:
> [...]
> Now I assign to each control the context menu it should get (if at
> all) - and (would you believe it) when clicked the menu can discover
> its 'SourceControl'.

I was gonna say…

Glad you worked it out. :)
From: eric on
Hi Helmut,

Sorry I answered a little bit too fast and forgot the object sender
would be a ContextMenuStrip.

Eric.

On 25 fév, 02:58, Helmut Giese <hgi...(a)ratiosoft.com> wrote:
> Hi Eric,
> thanks but this doesn't seem to be quite right:>The control that has been clicked is identified by the object "sender"
> >in your method cms_opening.
> >Analyze this object, convert it to the proper type and you have your
> >control.
>
> The 'sender' is a ContextMenuStrip and I have yet to find a way to
> identify the underlying control.
> Any other idea?
> Thanks and best regards
> Helmut Giese

From: Helmut Giese on
>Hi Helmut,
>
>Sorry I answered a little bit too fast and forgot the object sender
>would be a ContextMenuStrip.
No problem. See my 'reply to self' about SourceControl and how I
managed to confude myself.
Best regards
Helmut Giese

From: Helmut Giese on
On Wed, 24 Feb 2010 21:07:56 -0800, Peter Duniho
<no.peted.spam(a)no.nwlink.spam.com> wrote:

>Helmut Giese wrote:
>> [...]
>> Now I assign to each control the context menu it should get (if at
>> all) - and (would you believe it) when clicked the menu can discover
>> its 'SourceControl'.
>
>I was gonna say�
Ha, I beat you to it :)

From: Jeff Johnson on
"Jeff Johnson" <i.get(a)enough.spam> wrote in message
news:%2375D18VtKHA.5036(a)TK2MSFTNGP02.phx.gbl...

> private void cms_Opening(object sender, CancelEventArgs e)
> {
> ToolStripMenuItem item = (ToolStripMenuItem)sender;
> Control source = ((ContextMenuStrip)item.Owner).SourceControl;
> // And now you make decisions based on what source refers to
> }

Argh. For posterity, I have just realized that I took this code from a Click
event where it would be raised by a menu item. The Opening event, however,
is raised by the ContextMenuStrip itself, so there is no need to do all the
casting to ToolStripMenuItem and calling the Owner property to get the
ContextMenuStrip; sender IS the ContextMenuStrip.


First  |  Prev  | 
Pages: 1 2
Prev: Help with insert using MySql
Next: NET 4.0 and NET 3.5