Where can I find the Click event in the tree nodes?

I have a problem with treeview I cannot find a way to find the click event in each child node

Here's an example image enter image description here

here's what I've tried so far.

Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
    If TreeView1.SelectedNode.Level = 0 Then
    ElseIf TreeView1.SelectedNode.Level = 1 Then
    ElseIf TreeView1.SelectedNode.Level = 2 Then
    ElseIf TreeView1.SelectedNode.Level = 3 Then
    ElseIf TreeView1.SelectedNode.Level = 4 Then
    End If
End Sub


The problem is every child layer node in the message field it always says 2


source to share

1 answer

The event you are using is a good event. If you want to get the new selected node, just use the object EventArgs

in the event handler (parameter named e

). The following code is C #, not VB.Net, but it's very simple:

private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
    // Use the e parameter to get the new selected node




All Articles