?
Solved

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

Posted on 2004-10-08
6
Medium Priority
?
270 Views
Last Modified: 2010-04-15
When I select a node..........how can I determine programmatically if the node has children?
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 12261203
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.
0
 
LVL 5

Assisted Solution

by:Tertioptus
Tertioptus earned 1000 total points
ID: 12261724
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.:

treeView1.Nodes[0].Nodes.Count;



Basically you have to access the collection of nodes with a single node: i.e.  
TreeNode objNode = new TreeNode;
// population code
objNode.Nodes.Count
0
 
LVL 10

Accepted Solution

by:
Hans Langer earned 1000 total points
ID: 12273723
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");
      else
            MessageBox.Show("This Node Have Not ChildNodes");
}

GL
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Author Comment

by:Tom Knowlton
ID: 12346429
Expert GERENTE:

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.

:)

Tom
0
 
LVL 10

Expert Comment

by:Hans Langer
ID: 12346660
GERENTE means "Manager" in spanish too,
Im Engineer, not manager, and I live in Chile (South America).
;)
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 12346690
Cool!

or rather,

Que Otimo!

Tom  :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question