473,796 Members | 2,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

detect mouse event on node of a treeview

Sam
Hi,
I'd like to get the selected node when the user select a node in my
treeview. I know how to get the selected node, what I don't know is how
to detect that the user has selected a new node.

What methods should I use ?
thx

Nov 21 '05 #1
3 2000
I basically used a static variable to keep the old value of the
selected node and check to see if the new selected node was the same as
the old node. If not then I know they selected a new node.

Nov 21 '05 #2
"Sam" <sa************ **@voila.fr> schrieb:
I'd like to get the selected node when the user select a node in my
treeview. I know how to get the selected node, what I don't know is how
to detect that the user has selected a new node.


\\\
Private Sub TreeView1_After Select( _
ByVal sender As Object, _
ByVal e As TreeViewEventAr gs :
) Handles TreeView1.After Select
Static LastNode As TreeNode
Dim CurrentNode As TreeNode = _
Me.TreeView1.Ge tNodeAt(Me.Tree View1.PointToCl ient(Cursor.Pos ition))
If Not CurrentNode Is LastNode Then
LastNode = CurrentNode
If Not CurrentNode Is Nothing Then
MsgBox(CurrentN ode.Text)
Else
MsgBox("No node selected!")
End If
End If
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #3
Sam
thanks to both of you
finally here is what i've done

Private Sub tvRelations_Aft erSelect(ByVal sender As System.Object,
ByVal e As System.Windows. Forms.TreeViewE ventArgs) Handles
tvRelations.Aft erSelect

If tvRelations.Sel ectedNode.Nodes .Count = 0 Then
txtTable1.Text = tvRelations.Sel ectedNode.Paren t.ToString
txtTable2.Text = tvRelations.Sel ectedNode.ToStr ing
End If
End Sub

Nov 21 '05 #4

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

Similar topics

0
1752
by: Plumer | last post by:
Hello everyone, I am using MS .NET Framework 1.0 Version 1.0.3705 developing a C# client application using SQL Server on the server side. I am looking to implement drag & drop in a TreeView control. The operation takes place entirely within this single control. There is no need to provide for interaction with other controls, forms, applications etc. Both the drag source item (a TreeNode) and the drag target item (another TreeNode) are...
4
9416
by: Andrew Robinson | last post by:
I am using a TreeView to perform navigation and have a few nodes that need to generate a popup menu. For this, I use the SelectedNodeChanged event and then add the relevant "window.open" script to the page using the ClientScript.RegisterStartupScript method. This seems to work fine, but if the user clicks on the same node twice, the event doesn't fire a second time. I assume this is by design as the Node Selection hasn't changed, but...
2
2096
by: xuanqn09 | last post by:
Hi all, There a treeview and I want to handle event left mouse-down and mouse-up on any node. Default OnLButtonDown() and OnLButtonUp() can't be used on nodes, only outside them. I consume much time but unable to solve this problem. Pls help me
1
1793
by: MrNobody | last post by:
by default when you right click a tree the control selects the node if you add a right-click event (so that I can put sepearate ContextMenus depending on what type of node the user clicked on) then that default behavior is overrided, and it no longer selects the node the user right-clicked on. Now my event is wrong because I want to use SelectedNode but the SelectedNode turns out to be whatever was previously selected instead of what the...
6
1729
by: Proogeren | last post by:
I was wondering if there is a way to detect if the user clicks on a node in a treeview. I know of the onnodeclickchange event but this will not fire if you click on the same node twice (only fire the first time you click as the second time it will not be a node click changed event). Everytime the user clicks on the node I want to redirect him to another page. does anyone know how I can acheive this? Is there any way to detect if a node has...
1
5115
by: R.A.F. | last post by:
Hi, I would like simulate a mouse click on on of my treeview nodes when my form opens. for that i was thinking to use the same simple way as under C++ : SendMessage(TreeView.Nodes.Handle, WM_LBUTTONDOWN,0,0); but it does not work. i do not get any error message and application runs normally... just my first node is not selected (clicked).
1
4166
by: selvakumari | last post by:
Hi, i am new to C#, i have a multiselection treeview, where if i select a nodes with ctrl and shift corresponding nodes will be copied to another treenode, i want to unselect the childnode selection with ctrl and shift if parent node is selected. i think of disablin the mouse click event inside that treenode if parent node is selected?
2
3631
by: selvakumari | last post by:
Hi, i am new to C#, i have a multiselection treeview, where if i select a nodes with ctrl and shift corresponding nodes will be copied to another treenode, i want to unselect the childnode selection with ctrl and shift if parent node is selected. i think of disablin the mouse click event inside that treenode if parent node is selected?
7
6695
by: Barkingmadscot | last post by:
I am try to find out how to check if the mouse button is held down. The e.click =2 works, it allows me to enter the double click double. I what the single click to do some different and then a click and hold to allow the drag and drop
0
9673
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
10217
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
10168
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
10003
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
7546
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
6785
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
5440
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
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4114
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.