PC Review


Reply
Thread Tools Rate Thread

detect mouse event on node of a treeview

 
 
Sam
Guest
Posts: n/a
 
      31st Mar 2005
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

 
Reply With Quote
 
 
 
 
Grant Smith
Guest
Posts: n/a
 
      31st Mar 2005
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.

 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      31st Mar 2005
"Sam" <(E-Mail Removed)> 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_AfterSelect( _
ByVal sender As Object, _
ByVal e As TreeViewEventArgs :
) Handles TreeView1.AfterSelect
Static LastNode As TreeNode
Dim CurrentNode As TreeNode = _
Me.TreeView1.GetNodeAt(Me.TreeView1.PointToClient(Cursor.Position))
If Not CurrentNode Is LastNode Then
LastNode = CurrentNode
If Not CurrentNode Is Nothing Then
MsgBox(CurrentNode.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/>
 
Reply With Quote
 
Sam
Guest
Posts: n/a
 
      31st Mar 2005
thanks to both of you
finally here is what i've done

Private Sub tvRelations_AfterSelect(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles
tvRelations.AfterSelect

If tvRelations.SelectedNode.Nodes.Count = 0 Then
txtTable1.Text = tvRelations.SelectedNode.Parent.ToString
txtTable2.Text = tvRelations.SelectedNode.ToString
End If
End Sub

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select TreeView Node with cursor instead of mouse click ExcelMonkey Microsoft Excel Programming 1 24th Sep 2009 01:05 PM
SendMessage mouse click to treeview node R.A.F. Microsoft C# .NET 5 26th Nov 2007 11:53 AM
TreeView node remove: what event? pamelafluente@libero.it Microsoft VB .NET 2 14th Sep 2006 11:19 PM
Event on checked TreeView node? Brett Romero Microsoft C# .NET 4 11th Aug 2006 03:27 PM
TreeView Highlite Node on mouse-Over =?Utf-8?B?QnJpYW5ESA==?= Microsoft VB .NET 2 13th Jul 2005 01:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:37 AM.