views:

569

answers:

2

In the NodeMouseClick event I'm trying to load some objects from the Node.Tag. Before I do so I check e.Node.IsSelected. When run regularly IsSelected is false....if I stick a break point around there and check e.node.Isselected, the value changes on me and becomes true. Why?

+2  A: 

The NodeMouseClick event is raised before the selection actually changes. (When you click on the same node twice, the second time e.Node.IsSelected will certainly have been true.)

You could try handling the AfterSelect event, although that will also be raised when using the keyboard to navigate the treeview, which may even be better for your purposes.

Alan
Well there's my problem.
nportelli
A: 

I tried to recreate your problem but could not. When I click on a node for the first time this value is always false, whether I set a break point or not. If I click a node the second time the value is true.

If the node is selected by default the value will be true, but otherwise it will always return false on the first click.

DaveK
I'll admit what I'm doing is very messing and very poor UI design. But yes I check once and the value is false, a 2nd time, without stepping and it turns to true. I found that odd.
nportelli