Treeview - Parent node or not? How to tell?

  • Thread starter Thread starter David Hearn
  • Start date Start date
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!
 
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.
 
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.
 
Back
Top