What treeview node was selected
Still learning vb.net 2005 and was needing to know how to determine what treeview node was selected so I can fire an event. What I have so far is below and it don't work. Each of my nodes have unique names so I can tell them apart pretty easily. Working code examples are best for me since i'm still learning this stuff.
Private Sub TreeView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.Click
'Tc3p1 is the name of the specific node in this case. It's the 2nd child of a parent
If TreeView1.SelectedNode = Tc3p1 Then
'Do some stuff here
End If
End Sub
Re: What treeview node was selected
Quote:
Originally Posted by teamdad
Still learning vb.net 2005 and was needing to know how to determine what treeview node was selected so I can fire an event. What I have so far is below and it don't work. Each of my nodes have unique names so I can tell them apart pretty easily. Working code examples are best for me since i'm still learning this stuff.
Private Sub TreeView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.Click
'Tc3p1 is the name of the specific node in this case. It's the 2nd child of a parent
If TreeView1.SelectedNode = Tc3p1 Then
'Do some stuff here
End If
End Sub
I am learning also but I think this is what you are looking for:
VB Code:
If TreeView1.SelectedNode.Text = "Tc3p1" Then
'Do some stuff here
End If
Re: What treeview node was selected
Use the AfterSelect event, which is raised after a node is selected. In the AfterSelect event handler e.Node is the node that was selected.