Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello All,

I have a treeview for which i am filling the items dynamically. On clicking any item it has to navigate to the page specified in the url of the navigation frame. On first click it is navigating properly but on second click the treeview selected event is not getting fired. It only gets fired again when i click on someother tree view item and click back on my previous item. What could be the problem? How can i fix this?

Thanks in Advance,
Regards.
Posted

1 solution

The node is already selected, so the selected event will not fire again if you click the selected node a second time.

If you want something to happen everytime you click it, regardless if it is selected or not, use NodeMouseClick

Demo;

VB
'Add 3 Roots each with 3 children
    For i = 0 To 2
        Dim node As New TreeNode("Item" + i.ToString)

        For j = 0 To 2
            Dim childnode As New TreeNode("Child" + j.ToString)
            node.Nodes.Add(childnode)
        Next

        TreeView1.Nodes.Add(node)
    Next
End Sub

Private Sub TreeView1_NodeMouseClick(sender As Object, e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseClick
    Debug.WriteLine(e.Node.Text)
End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900