Click to See Complete Forum and Search --> : TreeNode beforeExpand Operation


gborges
May 28th, 2008, 02:08 PM
Hi all!

I would like to dynamically populate my tree. In order to do that, I would like to use the event beforeExpand.

When the user clicks on the node plus signal, I would like that my app requests some information, and so, it will add some children to the expanded node.

The problem is that I don't know how can I get the expanded node. How do I do it?

Thank you!

hspc
May 28th, 2008, 02:27 PM
In the event handler, use e.Node.
e is the TreeViewCancelEventArgs parameter passed to the event handler.

boudino
May 28th, 2008, 02:31 PM
What kind of tree control do you use? If it is the VS native one, than the BeforeExpand event has an argument of TreeViewCancelEventArgs (http://msdn.microsoft.com/en-us/library/system.windows.forms.treeviewcanceleventargs.aspx) type, which contains Node property. This Node is the node you are interested in.