Solved

How many parents a child has

Posted on 2004-10-08
3
229 Views
Last Modified: 2010-04-15
In a Tree View control how can I find out how many parents a selected node has?

For example:


Main  (has 0 "parents")
      Main Child  (has 1 "parents")
             Main Grandchild  (has 2 "parents")
                      Main Great Grandchild   (has 3 "parents")
                      Main Great Grandchild   (has 3 "parents")
                                Main Great Great Grandchild   (has 4 "parents")



0
Comment
Question by:knowlton
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
smegghead earned 500 total points
ID: 12260380
Yes..

tvMain.PathSeparator="\t"; // Set this to something which doesn't occur in any of your nodes.

TreeNode TN=MySelection;
Parents=TN.FullPath.Length-TN.FullPath.Replace("\t","").Length;

Smg
0
 
LVL 5

Author Comment

by:knowlton
ID: 12261164
Perfect!!!

From this I built a function which can tell me how many parents a child node has.......which I can call when the node is selected.

Yahoooo!
0
 
LVL 5

Author Comment

by:knowlton
ID: 12261193
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now