COURSE of the MONTH

Can TreeView Contorl automatically focus and un-focus by user right-clicking on a node without changing it's selected node?

Is there a property or do I have to write additional code for this behavior? Basicly, The behavior like in Active Directory Users and Computer, if the root node is selected and has focus but I right click on like the Users folder, the Users folder would then be highlited and a pop-up menu appears pertains to the Users folder. However, when I'm done wtih the pop-up of at this point I click on the empty area of the left pane, the root node would then again have the focus and it never lost the status as the "selected node"

The TreeView control in version 2.0 of the .NET Framework works that way.

0

lapuccaAuthor Commented: 2006-11-05

I am using vs2005, .net 2.0. Currently in my application's TreeView control, the selectedNode isn't changed when I right-click on another node and the pop-up menu for the clicked-node does pop up. But, the right-clicked Node doesn't get the focus (The node is not highlited). So it's looking weird with the selectedNode high-lited but my mouse is over the clicked-node.

Oh sorry, I did not read carefully enough: I thought the functionality you were looking for was the returning of focus to the root node (which it does), not the highlighting of the intermediate value. When I set the HideSelection property to false, the TreeView works exactly like the Active Directory Users and Computers one.

I do have my HideSelection set to false. When I right click on another node, the clicked-node does gain focus for a split seond when it's clicked but lose it back to the selected-node when the pop-up menu opens up. The AD User and Computer snap-in retains the fous until the pop-up is closed or selected-menu action is done and performed. Thanks.

0

lapuccaAuthor Commented: 2006-11-06

Oh, I can assign a contextMenustrip to a TreeNode? Do I do this in the designer and how? Currently, I'm calling the context menus when the node is clicked with button. Maybe that is the problem with the focus? Thanks.