Solved

How many parents a child has

Posted on 2004-10-08
3
228 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

16 Experts available now in Live!

Get 1:1 Help Now