473,466 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Treeview node right click

Hey guys,

I am trying to detect a node right click event, but I can't seem to find a
way do this.

The only way I found to get to a point where I know the user clicked the
node is by checking the afterselect event of the treeview control. The Event
arguments variable has an action property which tells me whether the user
clicked the node, or expand it or whatever.

NOW, the problem is that once I check if the action was a mouseclick, HOW DO
I KNOW WHAT BUTTON WAS CLICKED?

Thanks in advance.
Nov 20 '05 #1
2 14296
"Juan Romero" <ju******@optonline.net> schrieb:
I am trying to detect a node right click event


Quick and (very) Dirty:

\\\
Private Sub TreeView1_MouseUp( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs _
) Handles TreeView1.MouseUp
If e.Button = MouseButtons.Right Then
Dim n As TreeNode = Me.TreeView1.GetNodeAt(e.X, e.Y)
If Not n Is Nothing Then
Me.TreeView1.SelectedNode = n
Me.MenuItem1.Text = n.Text
Else
Me.MenuItem1.Text = "(no item selected)"
End If
Me.ContextMenu1.Show(Me.TreeView1, New Point(e.X, e.Y))
End If
End Sub
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #2
I don't remember what I did exactly, but I do remember that there is
something in the treeview properties for setting a context menu after you
drag Context menu onto the form.

Kim

"Juan Romero" <ju******@optonline.net> wrote in message
news:O9**************@tk2msftngp13.phx.gbl...
Hey guys,

I am trying to detect a node right click event, but I can't seem to find a
way do this.

The only way I found to get to a point where I know the user clicked the
node is by checking the afterselect event of the treeview control. The Event arguments variable has an action property which tells me whether the user
clicked the node, or expand it or whatever.

NOW, the problem is that once I check if the action was a mouseclick, HOW DO I KNOW WHAT BUTTON WAS CLICKED?

Thanks in advance.

Nov 20 '05 #3

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

Similar topics

3
by: vijaynats | last post by:
I have a treeview with a ContextMenu attached. When i click on a node, AfterSelect fires but does not fire when right clicked (the context menu pops up). (Background: I have loaded a list of...
1
by: Aleksey | last post by:
Hi, All! I have a problem with TreeView component. My TreeView consists of two nodes Node1 and Node2. On click of right mouse button TreeView has event. In this event I check wich node is...
5
by: A-PK | last post by:
Hi, I am using treeview as my menu. my menu is like the following + Users & Groups - Users -Groups + Departmenuts - Engineering
0
by: Treeview Trouble | last post by:
I have an application where there are two radio buttons each of which populates a treeview control with a directory structure. Each radio button corresponds to a different directory which may or...
3
by: Shawn | last post by:
Hi. I'm working with the TreeView control in my ASP.NET 1.1 application. I have a problem I haven't been able to figure out. When I click on a node (not expand), whether it's a parent node, a...
8
by: Matt MacDonald | last post by:
Hi All, I have a form that displays hierarchical categories in a treeview. Ok so far so good. What I was to do is have users be able to select a node in the treeview as part of filling out the...
4
by: Xenomorph | last post by:
I have a program where you click an item on the TreeView on the left, and then work with whatever pops up on the right. There are many entries on the TreeView, and when you click something on the...
18
by: =?Utf-8?B?TGkgV2VuZw==?= | last post by:
Hi, Is there a way for TreeView to have multiple selections? But I am not talking about its checked boxes. I want a way similar to ListView with MultiSelect = True. So I can use or key and...
1
by: johnnypung | last post by:
I have a treeview opening a contextMenuStrip on right click. However the right click would not select the node that it right clicks on. How should I make it so the right click will select the node,...
0
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I have a treeview setup on my page. In case it is relevant, it is set in an accordion, which is inside an update panel. When I click the treeview node, a page loads on the right side of my browser...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
1
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...
0
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.