hi guys,
i'm working on the context menu for the controls.
the problem i'm facing right now is like this :
i want to use one context menu for more then one controls lets say i
want to use one context menu for 3 treeview controls as 3 of them
shares same type of menu.
what i'm not able to do is, i can not idetify which control has invoke
the context menu's event. let say one of the treeview control has
invoke an event "Reset" from the context menu. all i need to do is, to
find out which treeview has invoked the event and needs to refill the
treeview control.
i tried to find out how to get the parent control but i failed to do
so.
tools
c#.net 2.0 (VS.NET 2005)
can anyone give me any kind of suggestion on this.
thanks,
Lucky
Larry Lard - 30 Aug 2006 15:01 GMT
> hi guys,
> i'm working on the context menu for the controls.
[quoted text clipped - 10 lines]
> i tried to find out how to get the parent control but i failed to do
> so.
In the ContextMenuStrip's Opening event, set a form-level private
variable to the ContextMenuStrip's SourceControl property. This is the
control that invoked the context menu. Then in the Reset item's handler,
you will be able to see who wants to be reset.
I wanted to avoid using a variable, and just put the SourceControl in
the *menu strip's* Tag property, but I couldn't work out how to get from
a ToolStripMenuItem to its containing menu - can anyone enlighten me?

Signature
Larry Lard
larrylard@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Mudhead - 30 Aug 2006 15:42 GMT
Private Sub ContextMenuStrip1_Opening(ByVal sender As Object, ByVal e As _
System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening
Debug.WriteLine(ContextMenuStrip1.SourceControl.Name.ToString)
End Sub
> hi guys,
> i'm working on the context menu for the controls.
[quoted text clipped - 18 lines]
> thanks,
> Lucky