473,322 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

treeView - deepest level


can anyone post an algoritam for the deepest level
of a treeView ? it should be a recursive function I think..

I don't need treeView.Nodes[x].Level
because my users don't select the nodes...
I need to get a random node from the whole collection
so I want my
rndLevel = random.next(deepest level)
rndNode = random.next(number of nodes on that level)
to be able to get any node on any level in the collection.

please help..
--
If a "7–11" is open 24 hours a day, 365 days a year, why are there locks on
the door?

—Nick Featherman
Mar 25 '07 #1
1 5066
for my problem, with having only one node without Parent
seems this works ok..

ArrayList list = new ArrayList();

private void btn1_Click(object sender, EventArgs e)
{
depth(treeView1.Nodes[0]);
list.Sort();
MessageBox.Show("Deepest level: " + list[list.Count-1].ToString
());
}

private void depth(TreeNode node)
{
for (int i = 0; i < node.Nodes.Count; i++)
{
depth(node.Nodes[i]);
list.Add(node.Nodes[i].Level);
}
}
Mar 25 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: WJA | last post by:
I'm looking at building an application that needs to display 4 levels of hierarchical data. Initially the obvious choice for this would seem to be the treeview control. After searching this...
42
by: lauren quantrell | last post by:
So many postings on not to use the treeview control, but nothing recently. Is it safe to swim there yet with Access 2000-Access 2003?
4
by: Jeroen Ceuppens | last post by:
Hi, I want to make something that adds a TreeNode to the end of TreeView, that TreeView Looks like + Level 1 + Level 2 + Level 3 - Level last
5
by: Jeroen Ceuppens | last post by:
I need to put a new node at the end of the tree, that end is not te lowest in de list but the deepest (the one with the most + before it) Node A Node 1 Node 2 Node 3 Node 4: Deepest Node B:...
3
by: Jan Wrage | last post by:
Hi! I would like to implement a treeview in my existing application. It should show my entire Active-Directory structure, i.e. all Groups, Containers and OUs. Could somebody help me with...
6
by: L.M | last post by:
Hello, I knew how to use the treeview under VB6. After migrating to .NET, well, I'm lost. I try to add a new node, either to the same level or as a child to a selected node in the treeview....
7
by: amruta | last post by:
the code below dows not let me get the parent child view... all the nodes are show in one line only... also i need them to be collasped ... Thanks ..
4
by: David Isaac | last post by:
I have a list of lists, N+1 deep. Like this (for N=2): ,],,]] I want to efficiently produce the same structure except that the utlimate lists are replaced by a chosen (by index) item. E.g.,...
4
by: frostbb | last post by:
I have a C# WinForms treeview with 20 or so 'level 0' nodes. My users will normally have 2 of the 'level 0' branches open down to a '5th level' selected node. The users will make updates to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.