views:

204

answers:

1

When I expand a TreeView node by clicking on the plus sign right to it, the node gets selected. How can I avoid this? I want to be able to expand nodes without changing the selected node (like in RegEdit.exe, for example), and only change selection when the node text is clicked .

(Forgive me for what seems to be a basic question - I did search around, but found nothing. Any pointers or links are welcome.)

A: 

I believe there is a BeforeSelect event you can tap into, which should allow you to cancel node selection if the selected node has children.

private void MyTreeView_BeforeSelect(object sender, TreeViewCancelEventArgs e)
{
 If (nodeWithChildren) e.Cancel = True
}
Sergey
Thank you for the comment. Is it possible to cancel node selection from BeforeExpand?
Uros Calakovic