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.

contextMenuStrip with TreeNodes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paitum - 04 Jul 2006 08:05 GMT
Dear WindowsForms Community,

I have a question about using ContextMenuStrips with TreeNodes.

Is there a clean OOP way of determining the TreeNode which was right-clicked
on within the Click event-handlers of my ContextMenuStrip?

private void addToolStripMenuItem_Click(object sender, EventArgs e)
{
    // sender is a ToolStripMenuItem object
    // e contains no information
    // contextMenuStrip.SourceControl is a TreeView
}

One would expect the contextMenuStrip.SourceControl to provide the TreeNode
registered to the menu, but instead it provides the TreeView.
JJ - 04 Jul 2006 22:58 GMT
I don't fully understand your question. I'm assuming that at the time the
right-click occurs the current TreeView.SelectedNode may/may not be the node
you want.
With this assumption, you can use the mouse location from your event to
locate the treenode under it. Of course the mouse location will be inside of
your ContextMenuStrip so you'll have add couple lines to map the mouse
location into the treeview and find the node.

Good luck
Jeff www.ruamkwamkid.com

> Dear WindowsForms Community,
>
[quoted text clipped - 12 lines]
> One would expect the contextMenuStrip.SourceControl to provide the
> TreeNode registered to the menu, but instead it provides the TreeView.

Rate this thread:







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.