473,836 Members | 2,303 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Treeview: right click doesn't select item?

I can detect a right click on my treeview, but SelectedNode.In dex points to
the last node that was left-clicked. Is there a way for a right-click event
of a treeview to update the SelectedNode.In dex?

Private Sub tvwTopics_Mouse up(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles tvwTopics.Mouse Up
If e.Button = MouseButtons.Ri ght Then
MsgBox("Right click " &
tvwTopics.Nodes (tvwTopics.Sele ctedNode.Index) .Text)
End If
End Sub

Thanks
Nov 20 '05 #1
2 7093
* "tmaster" <le*******@trav elmasterusa.com > scripsit:
I can detect a right click on my treeview, but SelectedNode.In dex points to
the last node that was left-clicked. Is there a way for a right-click event
of a treeview to update the SelectedNode.In dex?

Private Sub tvwTopics_Mouse up(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles tvwTopics.Mouse Up
If e.Button = MouseButtons.Ri ght Then
MsgBox("Right click " &
tvwTopics.Nodes (tvwTopics.Sele ctedNode.Index) .Text)
End If
End Sub


\\\
Private Sub TreeView1_Mouse Up( _
ByVal sender As Object, _
ByVal e As System.Windows. Forms.MouseEven tArgs _
) Handles TreeView1.Mouse Up
If e.Button = MouseButtons.Ri ght Then
Dim n As TreeNode = Me.TreeView1.Ge tNodeAt(e.X, e.Y)
If Not n Is Nothing Then
Me.TreeView1.Se lectedNode = n
Me.MenuItem1.Te xt = n.Text
Else
Me.MenuItem1.Te xt = "(no item selected)"
End If
Me.ContextMenu1 .Show(Me.TreeVi ew1, New Point(e.X, e.Y))
End If
End Sub
///

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


Here is a workaround for this Problem:

Private Sub ctl_TreeView_Mo useUp(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles ctl_TreeView.Mo useUp

Dim node As Windows.Forms.T reeNode

node = ctl_TreeView.Ge tNodeAt(e.X, e.Y)

If node Is Nothing Then Exit Sub

"tmaster" <le*******@trav elmasterusa.com > schrieb im Newsbeitrag
news:4I******** *********@fe1.c olumbus.rr.com. ..
I can detect a right click on my treeview, but SelectedNode.In dex points to the last node that was left-clicked. Is there a way for a right-click event of a treeview to update the SelectedNode.In dex?

Private Sub tvwTopics_Mouse up(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles tvwTopics.Mouse Up
If e.Button = MouseButtons.Ri ght Then
MsgBox("Right click " &
tvwTopics.Nodes (tvwTopics.Sele ctedNode.Index) .Text)
End If
End Sub

Thanks

Nov 20 '05 #3

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

Similar topics

6
2093
by: Etienne | last post by:
Hi, I have a form containing 2 TreeViews. When I click on a button, items are transfered from the left tree to the right tree, which causes flickering. In order to remove such flickering, I surrounded code with BeginUpdate/EndUpdate for both trees. The left tree doesn't flicker anymore, but the right one still does!! Even if I call BeginUpdate/EndUpdate on the right tree only, it still flickers. What's going on here? Is BeginUpdate working...
4
14191
by: Aaron Queenan | last post by:
How can I use the designer to add a context menu to a class which inherits from a control, e.g. treeview, without adding the context menu to a form? For example, to add a context menu with "Select All" and "Clear Selection" to a checked list box? Thanks, Aaron Queenan.
7
2107
by: Michael C | last post by:
Hi all, I half-resolved my previous TreeView issue. Now I was wondering if anyone knows of a way to keep a TreeNode from being highlighted when it is left-clicked? It seems like there should be an event I could intercept, or a property I could set, but I'll be darned if I can figure out which one... Thanks, Michael C., MCDBA
3
11636
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 disk file names onto the tree and have to open the file thru the contextmenu for editing. It opens the file whose treeview node was selected earlier using a left mouse click). Any solutions?
5
1565
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
7
3776
by: amruta | last post by:
the code below dows not let me get the parent child view... all the nodes are show in one line only... also i need them to be collasped ... Thanks ..
8
12787
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 form. I only want to allow single selection, so using checkboxes is out of the question. It works as is, but it makes the form very cumbersome if every time that a user selects a node, the whole page has to reload. Is there a way to have a node...
4
3011
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 right, the item on the TreeView is no longer highlighted, making it hard to keep track of which item you clicked on the TreeView. I want the item clicked on in the TreeView to turn BOLD, or get underlined, or change color or something. Just so...
18
15385
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 click to make multiple selections. Then when I simply click one item, all previous selections are gone. Thanks in advance.
0
9812
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
9657
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
10532
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
10577
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
10243
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
6975
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
5642
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...
2
4003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3103
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.