473,605 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ContextMenuStri p owner

In my program I dynamically create treeViews and dynamically add nodes to them.
To each node I attach ContextMenuStri p which suppose allow delete selected
node
e.t.c.

How from inside click event handling function to find which node was selected?
sender is set to ToolStripItem clicked.
Oct 5 '07 #1
1 5931
Hi lenusia,

You can retrieve the source by retrieving the ContextMenuStri p from the
ToolStripItem. You can retrieve the source control (the treeview you are
looking for) from the ContextMenuStri p.SourceControl . Like:
ToolStripMenuIt em tsItem = (ToolStripMenuI tem)sender;
ContextMenuStri p cMenuStrip = (ContextMenuStr ip)tsItem.Owner ;
Control theSourceContro l = cMenuStrip.Sour ceControl;
TreeView myTreeView = (TreeView)theSo urceControl;
MessageBox.Show (myTreeView.Nam e);

Note: you realy should check your objects before making explicit casts,
unless you are 100% shure nothing else could have raised the event.

Regards,

Nico
"Lenusia" wrote:
In my program I dynamically create treeViews and dynamically add nodes to them.
To each node I attach ContextMenuStri p which suppose allow delete selected
node
e.t.c.

How from inside click event handling function to find which node was selected?
sender is set to ToolStripItem clicked.
Oct 5 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2832
by: Wael_Bakr | last post by:
Hi I used to use one contextmenu for many controls when popup I had to get sourcecontrol property of sender to know owner control using 2005 beta contextmenustrip I don't find a similar property can any body help thanks in advance
1
2571
by: Ron M. Newman | last post by:
I have a context menu strip. I can Add elements to its "Items", but there is nothing in there to add a sub context menu strip. Menu Item 1 Item 2 Sub Item 1 <-- impossible to add! How do I achieve that? There seems no API's to do that and the internet is simply "empty" when it comes to that. All newsgroups questions are
7
7584
by: Dave | last post by:
How do I get my ContextMenuStrip to receive key down preview events? I have the event hooked but I don't see the key strokes in the event? Dave
5
15468
by: =?Utf-8?B?cHJvZ2dlcg==?= | last post by:
I've written an application that can minimize to the tray and can reappear if you double click on the icon in the tray (ShowInTaskbar is set to false). I've also created a ContextMenuStrip (Visual C# 2005) so that you can write click on the icon in the tray for options. I then captured the event for mouse clicks on the Notify Icon so that I could detect the left click event and then display the contextmenustrip using either:...
0
1701
by: active | last post by:
For the last 3 or 4 days I've been, on an off, searching the Internet and theVS2005 Doc for an example of how to add a contextmenustrip to a menustrip. I can move all the items from a contentmenustrip to a menustrip, but what I need to do is have the items in both places. I did see where it was said that a contexmenu can be used in multiple places. But I wonder if that means that multiple controls can reference the same contextmenustrip....
1
2254
by: =?Utf-8?B?QnJhZA==?= | last post by:
i have a menu system that is generated dynamically everything works good except for one minor astetic.... I click on a menu item that displays a ContextMenuStrip Popup Menu If an item on that ContextMenuStrip calls another ContextMenuStrip, i want the original ContextMenuStrip to stay visible until a choice is made on the second ContextMenuStrip.
7
7829
by: Joe Cool | last post by:
Let's say I have a Treeview control on a form. Each leaf node in the Treeview has a ContextMenuStrip, each with one ToolStripMenuItem, and all ToolStripMenuItems Click event is handled by a comment event handler. How do I determine which Treeview Node signalled the menu event in the common event handler?
9
2379
by: =?Utf-8?B?Z2luYWNyZXNzZQ==?= | last post by:
Hi, I have a form (Form1) with a ContextMenuStrip (ContextMenuStrip1). If I pass Form1 to a Utility Sub with the following code: Public Sub Utility(theForm as Object) with theForm For Each MenuItem As ToolStripMenuItem In .ContextMenuStrip1.Items If LCase(Strings.Left(MenuItem.Name, 8)) = LCase("tsmAudit") Then MenuItem.Enabled = False End If
2
3422
by: eBob.com | last post by:
I've been working on an app which has an array of RichTextBoxes. And I have a context menu for the RTBs. The context menu has two levels; the first level has two items, "Load Sample Text File" and "Insert Row >"; the "Insert Row >" item on the first level invokes, if that's the right word, a second level which has two items, "Above" and "Below". This all worked when it was a ContextMenu. But I am trying to change it to use the new menu...
0
8001
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8415
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8286
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6742
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3912
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3958
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2438
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.