473,705 Members | 5,086 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to handle TreeNode right click

Hey guys, I have a small problem here....

I have a treeview control. I want to display a popup menu when the user
right clicks on a node. This is no problem, and I am able to make the popup
come out.

However, when I want to perform an operation based on the node selected, I
find that the node actually gets selected after the popup goes away. In
other words, if I right click a random item in the treeview and the user
selects an operation from the popup, the treeview's selectednode property is
NOTHING.

Only if I select the item with a click first, and then do the right click,
the selectednode property is ok (obviously).

How can I handle this?

Thanks in advance.


Nov 20 '05 #1
1 2125
* "Juan Romero" <ju*********@bo wne.com> scripsit:
I have a treeview control. I want to display a popup menu when the user
right clicks on a node. This is no problem, and I am able to make the popup
come out.

However, when I want to perform an operation based on the node selected, I
find that the node actually gets selected after the popup goes away. In
other words, if I right click a random item in the treeview and the user
selects an operation from the popup, the treeview's selectednode property is
NOTHING.

Only if I select the item with a click first, and then do the right click,
the selectednode property is ok (obviously).


Have a look at the TreeView's 'GetNodeAt' method:

<http://makeashorterlin k.com/?K233612F3>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2

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

Similar topics

2
2129
by: worzel | last post by:
Can't suss this out for the life of me, googling of no help either. Okay, new to win forms; I have a treeview with several root nodes, each having a single level of child nodes underneath. I also havea context (popup) menu which, what I want, is for it to pop up with certain options (menuItems) when a root treeNode is selected and different options when a child node is selected. It is all working well except for one problem - if I right...
0
1437
by: Sean | last post by:
Hi, I am doing a desktop application and now I am having problem preventing the quick highlight of a treenode when a user right clicks a treenode. The reason I am doing this is that only when user right clicks exactly within the label of the treenode, that node will get selected, otherwise that node will not get selected.
2
6269
by: Sean | last post by:
Hi, I have a treeview and user can right click the treenodes, depending on the nodes, different shortcut menu will appear. I want only the shortcut menu to appear if the point of the right mouse click is within the label text of the treenode instead of row-wide.
1
2103
by: Harshad | last post by:
If I have a "Handle" of a TreeNode, how can I refer to the treenode? For example, if the treenode is tn then I want to get tn.Text or tn.Index. In other words, TreeNode has its pointer property as Handle, how do I crossreference? -- Thanks for your help. Harshad Rathod
2
10292
by: paradox | last post by:
How can I go about having a TreeNode selected when I right click? I tried using the Click event, but the event does not pass in the node that was clicked. Currently you have to left click a node in order to select it. I want to be able to write click and bring up a context menu with only certain options available depending on the node selected. I got the context menu to come up (which is very easy to do), however, you first have to left...
0
1840
by: fred | last post by:
I am using the clipboard to copy and paste a TreeNode but the Tag property does not seem to be copied. I use the Tag property for an Object that contains data relating to the TreeNode. The Tag property is fine when the TreeNode is put onto the Clipboard but the Tag property is always 'nothing' when I take the TreeNode from the Clipboard. Private Sub PutNodeOnClipboard(ByVal thisNode As TreeNode) Dim thisDataObject As New DataObject...
0
1435
by: Marc Bartsch | last post by:
Hi, I have a WinForms application (C#, VS 2005) that consists of a treeview control and a notify icon. Below is a complete example of this application. The treeview has one root node and one child node. When I close the form, it will not be closed but minimised to the system tray. A double-click on the notify icon wakes it up and displays it again. My expection was that the treeview handle would be destroyed when the form is sent to the...
0
3309
by: divya1949 | last post by:
Create a windows c# application which will Read a xml file and populate nodes in the treeview. 1 On selection of treenode display the child nodes of that node in listview control 2. Provide following view properties to listview, through View menu a. Tile b. Icon
0
1539
by: Tom | last post by:
I have your classic WinForm treeview that uses an image list with 2 images: 1. An open folder. 2. A closed folder. The events that I have registered for are: 1. afterselect 2. afterexpand 3. aftercollapse The AfterExpand and AfterCollapse events set the imageindex appropriately,
0
8768
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
8690
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9274
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8979
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...
1
6606
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
5933
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2491
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2083
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.