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 / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

How to find the parent form for a ContextMenuStrip

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alexander - 12 Jul 2006 13:48 GMT
Hi,

I have a ContextMenuStrip that is used on various forms. When somebody opens
the context menu on a specific form (e.g. Form2) and clicks a menu item, I
need to execute some action on that form. Is there a way to determine the
form from which the context menu was invoked in the click event handler?  

Usually I do this with Control.FindForm() but that does not work for the
ContextMenu.

Thanks for your help.
Techno_Dex - 12 Jul 2006 20:55 GMT
Two things to try.  First, try the cmsContextMenuStrip.SourceControl, which
should get you the parent of the current context menu.  This might be a
ToolStrip or something completely different.  The second option is to try
the cmsContextMenuStrip.TopLevelControl.  This should get you the Form which
is the top level control not being parented by any other Control.

> Hi,
>
[quoted text clipped - 8 lines]
>
> Thanks for your help.

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.