473,545 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't find deepest node


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: not this one

I need to Put everytime a new child to the Deepest so:

first:
Node A

then

Node A
Node 1

then

Node A
Node 1
Node 2

and so on

I tried many things, like TreeNodeCollect ion and
treeViewSequenc e.Nodes.GetEnum erator() But i can't find a way to fix this,
it is difficult to get the child, help me....

Thx
JC

Nov 15 '05 #1
5 3283
As I told before, there's no pre-defined method/property for your problem.
You need to come up with an algorithm.... Do you think something like this
will solve your problem?

TreeNode deepest;
int deepestLevel = 0;
foreach (TreeNode node in treeView.Nodes)
{
// This will get all the top level nodes - and now, let's iterate
// through each one.
int level = 0;
while (node.Nodes.Cou nt > 0)
{
level++;
node = node.Nodes[0];
}

// Check if we hit the deepest
if (level >= deepestLevel)
deepestNode = node;
}

// Now, add your new node to the deepest node
deepestNode.Nod es.Add(newNode) ;

-vJ

"Jeroen Ceuppens" <je************ *@barco.com> wrote in message
news:eg******** ******@TK2MSFTN GP10.phx.gbl...

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: not this one

I need to Put everytime a new child to the Deepest so:

first:
Node A

then

Node A
Node 1

then

Node A
Node 1
Node 2

and so on

I tried many things, like TreeNodeCollect ion and
treeViewSequenc e.Nodes.GetEnum erator() But i can't find a way to fix this,
it is difficult to get the child, help me....

Thx
JC

Nov 15 '05 #2
Sorry - small correction... Check below

"Vijaye Raji" <no************ @hotmail.com> wrote in message
news:9a******** ************@co mcast.com...
As I told before, there's no pre-defined method/property for your problem.
You need to come up with an algorithm.... Do you think something like this will solve your problem?

TreeNode deepest;
int deepestLevel = 0;
foreach (TreeNode node in treeView.Nodes)
{
// This will get all the top level nodes - and now, let's iterate
// through each one.
int level = 0;
while (node.Nodes.Cou nt > 0)
{
level++;
node = node.Nodes[0];
}

// Check if we hit the deepest
if (level >= deepestLevel) { deepestNode = node;
// CORRECTION: This line is important.
deepestLevel = level
} }

// Now, add your new node to the deepest node
deepestNode.Nod es.Add(newNode) ;

-vJ

"Jeroen Ceuppens" <je************ *@barco.com> wrote in message
news:eg******** ******@TK2MSFTN GP10.phx.gbl...

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: not this one

I need to Put everytime a new child to the Deepest so:

first:
Node A

then

Node A
Node 1

then

Node A
Node 1
Node 2

and so on

I tried many things, like TreeNodeCollect ion and
treeViewSequenc e.Nodes.GetEnum erator() But i can't find a way to fix this, it is difficult to get the child, help me....

Thx
JC


Nov 15 '05 #3
Thx!

There is still a problem:

C:\Documents and Settings\Eindwe rk\Mijn documenten\BARC O\Eindwerk\Proj ect
Files\thuis\29n ovember\TestTre e\Form1.cs(206) : Property or indexer
'System.Windows .Forms.TreeNode .Parent' cannot be assigned to -- it is read
only

this error i get on node = node.Nodes[0];
Do you know what i can do to make it not read only?

Thx
JC
"Vijaye Raji" <no************ @hotmail.com> schreef in bericht
news:-Y************** ******@comcast. com...
Sorry - small correction... Check below

"Vijaye Raji" <no************ @hotmail.com> wrote in message
news:9a******** ************@co mcast.com...
As I told before, there's no pre-defined method/property for your problem.
You need to come up with an algorithm.... Do you think something like

this
will solve your problem?

TreeNode deepest;
int deepestLevel = 0;
foreach (TreeNode node in treeView.Nodes)
{
// This will get all the top level nodes - and now, let's iterate
// through each one.
int level = 0;
while (node.Nodes.Cou nt > 0)
{
level++;
node = node.Nodes[0];
}

// Check if we hit the deepest
if (level >= deepestLevel)

{
deepestNode = node;


// CORRECTION: This line is important.
deepestLevel = level
}
}

// Now, add your new node to the deepest node
deepestNode.Nod es.Add(newNode) ;

-vJ

"Jeroen Ceuppens" <je************ *@barco.com> wrote in message
news:eg******** ******@TK2MSFTN GP10.phx.gbl...

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: not this one

I need to Put everytime a new child to the Deepest so:

first:
Node A

then

Node A
Node 1

then

Node A
Node 1
Node 2

and so on

I tried many things, like TreeNodeCollect ion and
treeViewSequenc e.Nodes.GetEnum erator() But i can't find a way to fix this, it is difficult to get the child, help me....

Thx
JC



Nov 15 '05 #4
Ok.. My mistake... objects from foreach are read-only.

Here's a modified version:

TreeNode deepestNode = null;
int deepestLevel = 0;
foreach (TreeNode node in treeView1.Nodes )
{
// This will get all the top level nodes - and now, let's
iterate
// through each one.
int level = 0;
TreeNode nodeTemp = node;
while (nodeTemp.Nodes .Count > 0)
{
level++;
nodeTemp = nodeTemp.Nodes[0];
}

// Check if we hit the deepest
if (level >= deepestLevel)
{
deepestNode = nodeTemp;
deepestLevel = level;
}
}
// Now add your new node
deepestNode.Nod es.Add(newNode) ;

-vJ

"Jeroen Ceuppens" <je************ *@barco.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Thx!

There is still a problem:

C:\Documents and Settings\Eindwe rk\Mijn documenten\BARC O\Eindwerk\Proj ect
Files\thuis\29n ovember\TestTre e\Form1.cs(206) : Property or indexer
'System.Windows .Forms.TreeNode .Parent' cannot be assigned to -- it is read
only

this error i get on node = node.Nodes[0];
Do you know what i can do to make it not read only?

Thx
JC
"Vijaye Raji" <no************ @hotmail.com> schreef in bericht
news:-Y************** ******@comcast. com...
Sorry - small correction... Check below

"Vijaye Raji" <no************ @hotmail.com> wrote in message
news:9a******** ************@co mcast.com...
As I told before, there's no pre-defined method/property for your problem. You need to come up with an algorithm.... Do you think something like

this
will solve your problem?

TreeNode deepest;
int deepestLevel = 0;
foreach (TreeNode node in treeView.Nodes)
{
// This will get all the top level nodes - and now, let's iterate
// through each one.
int level = 0;
while (node.Nodes.Cou nt > 0)
{
level++;
node = node.Nodes[0];
}

// Check if we hit the deepest
if (level >= deepestLevel)

{
deepestNode = node;


// CORRECTION: This line is important.
deepestLevel = level
}
}

// Now, add your new node to the deepest node
deepestNode.Nod es.Add(newNode) ;

-vJ

"Jeroen Ceuppens" <je************ *@barco.com> wrote in message
news:eg******** ******@TK2MSFTN GP10.phx.gbl...
>
> 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: not this one
>
> I need to Put everytime a new child to the Deepest so:
>
> first:
> Node A
>
> then
>
> Node A
> Node 1
>
> then
>
> Node A
> Node 1
> Node 2
>
> and so on
>
> I tried many things, like TreeNodeCollect ion and
> treeViewSequenc e.Nodes.GetEnum erator() But i can't find a way to fix

this,
> it is difficult to get the child, help me....
>
> Thx
> JC
>
>
>



Nov 15 '05 #5
YEAH! it works!

Thx a lot dude!

Greetz
JC
"Vijaye Raji" <no************ @hotmail.com> schreef in bericht
news:e5******** ******@TK2MSFTN GP10.phx.gbl...
Ok.. My mistake... objects from foreach are read-only.

Here's a modified version:

TreeNode deepestNode = null;
int deepestLevel = 0;
foreach (TreeNode node in treeView1.Nodes )
{
// This will get all the top level nodes - and now, let's
iterate
// through each one.
int level = 0;
TreeNode nodeTemp = node;
while (nodeTemp.Nodes .Count > 0)
{
level++;
nodeTemp = nodeTemp.Nodes[0];
}

// Check if we hit the deepest
if (level >= deepestLevel)
{
deepestNode = nodeTemp;
deepestLevel = level;
}
}
// Now add your new node
deepestNode.Nod es.Add(newNode) ;

-vJ

"Jeroen Ceuppens" <je************ *@barco.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Thx!

There is still a problem:

C:\Documents and Settings\Eindwe rk\Mijn documenten\BARC O\Eindwerk\Proj ect Files\thuis\29n ovember\TestTre e\Form1.cs(206) : Property or indexer
'System.Windows .Forms.TreeNode .Parent' cannot be assigned to -- it is read only

this error i get on node = node.Nodes[0];
Do you know what i can do to make it not read only?

Thx
JC
"Vijaye Raji" <no************ @hotmail.com> schreef in bericht
news:-Y************** ******@comcast. com...
Sorry - small correction... Check below

"Vijaye Raji" <no************ @hotmail.com> wrote in message
news:9a******** ************@co mcast.com...
> As I told before, there's no pre-defined method/property for your

problem.
> You need to come up with an algorithm.... Do you think something like this
> will solve your problem?
>
> TreeNode deepest;
> int deepestLevel = 0;
> foreach (TreeNode node in treeView.Nodes)
> {
> // This will get all the top level nodes - and now, let's iterate > // through each one.
> int level = 0;
> while (node.Nodes.Cou nt > 0)
> {
> level++;
> node = node.Nodes[0];
> }
>
> // Check if we hit the deepest
> if (level >= deepestLevel)
{
> deepestNode = node;

// CORRECTION: This line is important.
deepestLevel = level
}
> }
>
> // Now, add your new node to the deepest node
> deepestNode.Nod es.Add(newNode) ;
>
> -vJ
>
> "Jeroen Ceuppens" <je************ *@barco.com> wrote in message
> news:eg******** ******@TK2MSFTN GP10.phx.gbl...
> >
> > 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: not this one
> >
> > I need to Put everytime a new child to the Deepest so:
> >
> > first:
> > Node A
> >
> > then
> >
> > Node A
> > Node 1
> >
> > then
> >
> > Node A
> > Node 1
> > Node 2
> >
> > and so on
> >
> > I tried many things, like TreeNodeCollect ion and
> > treeViewSequenc e.Nodes.GetEnum erator() But i can't find a way to fix this,
> > it is difficult to get the child, help me....
> >
> > Thx
> > JC
> >
> >
> >
>
>



Nov 15 '05 #6

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

Similar topics

3
1334
by: mike | last post by:
I have an xml structure like: <data> <struct>1,8,7,30</struct> </data> and I need to develop a test that finds this node in each of these cases, something like: should find because 1 is in the node
3
1554
by: pentium77 | last post by:
Basically I have a situation where I need to update changes occuring in one Text field of a table into another text field located in another table. In addition both the tables are located in different frames of a HTML page. So my question is can such an update be done ? Is it necessary that the tables be located in the same frame for the...
3
5483
by: Robert Oschler | last post by:
What's a good way to find a specific text node element in a web page's DOM tree? I thought of traversing each node but there has to be a faster way. Is there a "find text node by nodeValue" function or something? I do know the nodeValue (text string) of the text node. Thanks.
4
1355
by: Gregory Piñero | last post by:
Hi, Would anyone be able to tell me why my function below is getting stuck in infinite recusion? Maybe I'm just tired and missing something obvious? def replace_within_node(node,oldnode,newnode): if node is oldnode: return newnode else:
3
6780
by: Goran Djuranovic | last post by:
Hi All, Does anyone know how to retreive deepest XPath value from XML document by using VB.NET? For example, if I had an XML file like this: <Root> <Customer> <Name>MyName</Name> </Customer> </Root> I would like to retreive "\Root\Customer\Name" out of it. Something like:
0
1148
by: Goran Djuranovic | last post by:
Hi All, Does anyone know how to retreive deepest XPath value from XML document by using VB.NET? For example, if I had an XML file like this: <Root> <Customer> <Name>MyName</Name> </Customer> </Root> I would like to retreive "\Root\Customer\Name" out of it. Something like:
7
3177
by: mattrapoport | last post by:
Hello - I am kinda new to the HTML DOM so I apologize in advance for my ignorance. I have a table made from divs. I am trying to write a script that appends a new row to the table (by cloning the last row) and then adding some text to the fields in that row. My script works perfectly in IE but not even close in Firefox. Here's my HTML...
1
5083
by: Bllich | last post by:
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.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...
1
2553
SamKL
by: SamKL | last post by:
Hey, I'm no expert on PHP, and I have somewhat of an understanding of object oriented code. Anyway, getting right to the problem. I'm using PHP4, so base it off of that. Basically I have 2 classes in this code. Link_Structure, which is composed of Node classes (it's a linked list data structure), and of course the Node class. In class...
0
7453
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7647
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7410
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7742
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4940
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3436
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1865
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1007
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.