none
TreeView node visually unselected after selecting tree node and then clicking soem other field

    Question

  • Hello,

    I am using .NET 3.5 (VS 2008).  I have a SplitContainer with a TreeView on one side and a form with various fields, tabs, etc on the other.  When I select one of the tree nodes, the node is highlighted.  The node loses its highlighting when the user clicks on one of the tabs or enters a field on the other side of the SplitContainer.  Although no highlighting is visible, the treeView.SelectNode() still returns the proper node, so it appears that the tree node is still selected, just not visually highlighted.  The problem is that without the highlighting to distinguish which node is selected, the user can easily get lost.  Is there a build-in mechanism to maintain some sort of highlighting on the selected node when the cursor is moved to another form.  For example, in Windows Explorer, if you select a tree node, the node is highlighted in a dark blue.  If you were to then place the cursor in the Address box, the selected node changes to have a beige color.  This still shows which node was selected.

    Is there a built-in solution (ie some property to set on the tree view or nodes) that would help fix my issue or do I have to build my own solution to mimic something like what Windows Explorer does?  I wanted to avoid having to put event handlers on all tabs and form fields that would be used to "re-highlight" the tree node.

    Any thoughts would be greatly appreciated - Peter 

    Tuesday, September 21, 2010 4:27 PM

Answers

  • Yes, set the HideSelection property of the TreeView to False.

    Honestly, I don't even know why the default is True. It doesn't seem like anyone ever wants that behavior. But oh well.

    • Marked as answer by Helen Zhou Friday, September 24, 2010 7:36 AM
    Tuesday, September 21, 2010 4:48 PM

All replies

  • Yes, set the HideSelection property of the TreeView to False.

    Honestly, I don't even know why the default is True. It doesn't seem like anyone ever wants that behavior. But oh well.

    • Marked as answer by Helen Zhou Friday, September 24, 2010 7:36 AM
    Tuesday, September 21, 2010 4:48 PM
  • Shawn,

    Yes, that works perfectly.  I agree with you.  It seems the default option for that should be reversed.

    Thanks for saving me alot of wasted time - Peter

    Tuesday, September 21, 2010 4:54 PM