Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / August 2006

Tip: Looking for answers? Try searching our database.

how to get parent control of the context menu stip

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lucky - 30 Aug 2006 13:06 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.