Treeview - Parent node or not? How to tell?

D

David Hearn

I have some code in the AfterSelect event of the Treeview control but
I only want it to fire if they have selected one of the child items of
the parent node. How can I tell?

Thanks in advance!
 
M

Martin Robins

David,

Try the following ...

private void OnAfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) {
if (e.Node.Parent != null) {
...
}
}

It will ensure that you only process the OnAfterSelect if the selected node has a parent.
 
D

David Hearn

Thanks Martin!


David,

Try the following ...

private void OnAfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) {
if (e.Node.Parent != null) {
...
}
}

It will ensure that you only process the OnAfterSelect if the selected node has a parent.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top