• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 613
  • Last Modified:

TreeView focus

I have a problem.  I have a treeview on the left of my form and a tabcontrol with tabs on the right.  When I click on a Treeview node I am controlling behavior via the Treeview_AfterSelect.  This works great.  However, if I click on a node the "Treeview_AfterSelect" fires, then click on a tab in the Tabcontrol, then click the same node back in the Treeview, the "Treeview_AfterSelect" does not fire for a second time.  

How do I make this work?

Thank you very much,

1 Solution
Mike TomlinsonMiddle School Assistant TeacherCommented:
The simplest solution is to unselect the node after it has been selected.  Then when you click on it again, it will be reselected and the AfterSelect() event will fire:

    Private Sub TreeView1_AfterSelect1(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
        ' Do some stuff in here
        TreeView1.SelectedNode = Nothing
    End Sub

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now