By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,640 Members | 1,331 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,640 IT Pros & Developers. It's quick & easy.

Which node on the tree view was clicked?

P: n/a
Dan
Anyone have any code to place in this procedure to determine what node
on my tree view was clicked?

Private Sub TreeView1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TreeView1.Click

End Sub

Thanks in advance.
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Dan,

try

MsgBox(TreeView1.SelectedNode.Text)

you can return any of the node properties this way, not
just text.

Good luck,

Jason
On 17 Jul 2004 10:09:14 -0700, ko****@yahoo.com (Dan) wrote:
Anyone have any code to place in this procedure to determine what node
on my tree view was clicked?

Private Sub TreeView1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TreeView1.Click

End Sub

Thanks in advance.


Nov 20 '05 #2

P: n/a
* ko****@yahoo.com (Dan) scripsit:
Anyone have any code to place in this procedure to determine what node
on my tree view was clicked?


\\\
Private Sub TreeView1_MouseUp( _
ByVal sender As Object, _
ByVal e As 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]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3

P: n/a
Dan
Thank you so much. I have discovered this code:

Private Sub TreeView1_AfterSelect_1(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles
TreeView1.AfterSelect
MsgBox(e.Node.ToString)
End Sub

From:

http://msdn.microsoft.com/library/de...iewcontrol.asp

It does the job. Thanks a bunch.

Dan
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.