Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

TreeView control....does a child node have children?

When I select a can I determine programmatically if the node has children?
Tom Knowlton
Tom Knowlton
  • 3
  • 2
2 Solutions
Tom KnowltonWeb developerAuthor Commented:
I guess just a COUNT of how many children would be best.....and if the COUNT is > 0 I can make a decision based on that.
try this, say if your TreeView control name is treeView1, and it has at least one node, then this line of code should work as is.  Of course you can modify it your on configuration.:


Basically you have to access the collection of nodes with a single node: i.e.  
TreeNode objNode = new TreeNode;
// population code
Hans LangerCommented:
Hi, Try this code,

this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
      if (e.Node.Nodes.Count > 0)
            MessageBox.Show("This Node Have " + e.Node.Nodes.Count.ToString() + " Nodes");
            MessageBox.Show("This Node Have Not ChildNodes");

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tom KnowltonWeb developerAuthor Commented:

Something about your name kept tickling the back of my mind.

"GERENTE" means "Manager" in Portuguese!  So are you a manager?

I spent a few years down in Sao Paulo, Brazil.

Mystery solved for my tireless subconscience.


Hans LangerCommented:
GERENTE means "Manager" in spanish too,
Im Engineer, not manager, and I live in Chile (South America).
Tom KnowltonWeb developerAuthor Commented:

or rather,

Que Otimo!

Tom  :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now