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 TreeNodeCollection and
treeViewSequence.Nodes.GetEnumerator() But i can't find a way to fix this,
it is difficult to get the child, help me....
Thx
JC 5 3177
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.Count > 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.Nodes.Add(newNode);
-vJ
"Jeroen Ceuppens" <je*************@barco.com> wrote in message
news:eg**************@TK2MSFTNGP10.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 TreeNodeCollection and treeViewSequence.Nodes.GetEnumerator() But i can't find a way to fix this, it is difficult to get the child, help me....
Thx JC
Sorry - small correction... Check below
"Vijaye Raji" <no************@hotmail.com> wrote in message
news:9a********************@comcast.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.Count > 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.Nodes.Add(newNode);
-vJ
"Jeroen Ceuppens" <je*************@barco.com> wrote in message news:eg**************@TK2MSFTNGP10.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 TreeNodeCollection and treeViewSequence.Nodes.GetEnumerator() But i can't find a way to fix
this, it is difficult to get the child, help me....
Thx JC
Thx!
There is still a problem:
C:\Documents and Settings\Eindwerk\Mijn documenten\BARCO\Eindwerk\Project
Files\thuis\29november\TestTree\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********************@comcast.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.Count > 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.Nodes.Add(newNode);
-vJ
"Jeroen Ceuppens" <je*************@barco.com> wrote in message news:eg**************@TK2MSFTNGP10.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 TreeNodeCollection and treeViewSequence.Nodes.GetEnumerator() But i can't find a way to fix this, it is difficult to get the child, help me....
Thx JC
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.Nodes.Add(newNode);
-vJ
"Jeroen Ceuppens" <je*************@barco.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... Thx!
There is still a problem:
C:\Documents and Settings\Eindwerk\Mijn documenten\BARCO\Eindwerk\Project Files\thuis\29november\TestTree\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********************@comcast.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.Count > 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.Nodes.Add(newNode);
-vJ
"Jeroen Ceuppens" <je*************@barco.com> wrote in message news:eg**************@TK2MSFTNGP10.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 TreeNodeCollection and > treeViewSequence.Nodes.GetEnumerator() But i can't find a way to fix this, > it is difficult to get the child, help me.... > > Thx > JC > > >
YEAH! it works!
Thx a lot dude!
Greetz
JC
"Vijaye Raji" <no************@hotmail.com> schreef in bericht
news:e5**************@TK2MSFTNGP10.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.Nodes.Add(newNode);
-vJ
"Jeroen Ceuppens" <je*************@barco.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... Thx!
There is still a problem:
C:\Documents and Settings\Eindwerk\Mijn
documenten\BARCO\Eindwerk\Project Files\thuis\29november\TestTree\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********************@comcast.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.Count > 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.Nodes.Add(newNode); > > -vJ > > "Jeroen Ceuppens" <je*************@barco.com> wrote in message > news:eg**************@TK2MSFTNGP10.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 TreeNodeCollection and > > treeViewSequence.Nodes.GetEnumerator() But i can't find a way to
fix this, > > it is difficult to get the child, help me.... > > > > Thx > > JC > > > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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"...
|
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...
|
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>...
|
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>...
|
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...
|
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...
|
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...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
|
by: Johno34 |
last post by:
I have this click event on my form. It speaks to a Datasheet Subform
Private Sub Command260_Click()
Dim r As DAO.Recordset
Set r = Form_frmABCD.Form.RecordsetClone
r.MoveFirst
Do
If...
|
by: jack2019x |
last post by:
hello, Is there code or static lib for hook swapchain present?
I wanna hook dxgi swapchain present for dx11 and dx9.
| |