473,396 Members | 2,139 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,396 software developers and data experts.

add a child node , tree view

I am putting data from DataTable to treeView

foreach( DataRow aRow in aTable.Rows)
{
TreeNode tnode = new TreeNode(aRow[1].ToString() + aRow[2].ToString() +
" " + aRow[3].ToString());
treeView1.Nodes.Add(tnode);
//till here code works fine
//now I wanna add child nodes for last inserted node
foreach( DataRow GrupaRow in TabelaGrupe.Rows)
{
if(statment)
{
TreeNode tnodegr = new TreeNode(GrupaRow[2].ToString()
+ " " + GrupaRow[3].ToString());
//what should I write here to put node tnodegr as a child to last
inserted tnode
treeView1.Nodes.Add(tnodegr);//????
}
}
treeView1.ExpandAll();
}
Nov 16 '05 #1
12 20495
foreach( DataRow aRow in aTable.Rows)
{
TreeNode tnode = new TreeNode(aRow[1].ToString() + aRow[2].ToString() +
" " + aRow[3].ToString());
//till here code works fine
//now I wanna add child nodes for last inserted node
foreach( DataRow GrupaRow in TabelaGrupe.Rows)
{
if(statment)
{
TreeNode tnodegr = new TreeNode(GrupaRow[2].ToString()
+ " " + GrupaRow[3].ToString());
tnode.Nodes.Add(tnodegr);
treeView1.Nodes.Add(tnode);
}
}
treeView1.ExpandAll();
}
"Dino L." <se******@gmail.com> wrote in message
news:Ob**************@TK2MSFTNGP12.phx.gbl...
I am putting data from DataTable to treeView

foreach( DataRow aRow in aTable.Rows)
{
TreeNode tnode = new TreeNode(aRow[1].ToString() + aRow[2].ToString() +
" " + aRow[3].ToString());
treeView1.Nodes.Add(tnode);
//till here code works fine
//now I wanna add child nodes for last inserted node
foreach( DataRow GrupaRow in TabelaGrupe.Rows)
{
if(statment)
{
TreeNode tnodegr = new TreeNode(GrupaRow[2].ToString()
+ " " + GrupaRow[3].ToString());
//what should I write here to put node tnodegr as a child to last
inserted tnode
treeView1.Nodes.Add(tnodegr);//????
}
}
treeView1.ExpandAll();
}

Nov 16 '05 #2
foreach( DataRow aRow in aTable.Rows)
{
TreeNode tnode = new TreeNode(aRow[1].ToString() + aRow[2].ToString() +
" " + aRow[3].ToString());
//till here code works fine
//now I wanna add child nodes for last inserted node
foreach( DataRow GrupaRow in TabelaGrupe.Rows)
{
if(statment)
{
TreeNode tnodegr = new TreeNode(GrupaRow[2].ToString()
+ " " + GrupaRow[3].ToString());
tnode.Nodes.Add(tnodegr);
treeView1.Nodes.Add(tnode);
}
}
treeView1.ExpandAll();
}
"Dino L." <se******@gmail.com> wrote in message
news:Ob**************@TK2MSFTNGP12.phx.gbl...
I am putting data from DataTable to treeView

foreach( DataRow aRow in aTable.Rows)
{
TreeNode tnode = new TreeNode(aRow[1].ToString() + aRow[2].ToString() +
" " + aRow[3].ToString());
treeView1.Nodes.Add(tnode);
//till here code works fine
//now I wanna add child nodes for last inserted node
foreach( DataRow GrupaRow in TabelaGrupe.Rows)
{
if(statment)
{
TreeNode tnodegr = new TreeNode(GrupaRow[2].ToString()
+ " " + GrupaRow[3].ToString());
//what should I write here to put node tnodegr as a child to last
inserted tnode
treeView1.Nodes.Add(tnodegr);//????
}
}
treeView1.ExpandAll();
}

Nov 16 '05 #3
A small change

foreach( DataRow aRow in aTable.Rows)
{
TreeNode tnode = new TreeNode(aRow[1].ToString() + aRow[2].ToString() +
" " + aRow[3].ToString());
//till here code works fine
//now I wanna add child nodes for last inserted node
foreach( DataRow GrupaRow in TabelaGrupe.Rows)
{
if(statment)
{
TreeNode tnodegr = new TreeNode(GrupaRow[2].ToString()
+ " " + GrupaRow[3].ToString());
tnode.Nodes.Add(tnodegr);
}
}
treeView1.Nodes.Add(tnode);
}
treeView1.ExpandAll();

"Chester Ragel" <CR****@Virtusa.com> wrote in message
news:eo**************@TK2MSFTNGP14.phx.gbl...
foreach( DataRow aRow in aTable.Rows)
{
TreeNode tnode = new TreeNode(aRow[1].ToString() + aRow[2].ToString() +
" " + aRow[3].ToString());
//till here code works fine
//now I wanna add child nodes for last inserted node
foreach( DataRow GrupaRow in TabelaGrupe.Rows)
{
if(statment)
{
TreeNode tnodegr = new TreeNode(GrupaRow[2].ToString()
+ " " + GrupaRow[3].ToString());
tnode.Nodes.Add(tnodegr);
treeView1.Nodes.Add(tnode);
}
}
treeView1.ExpandAll();
}
"Dino L." <se******@gmail.com> wrote in message
news:Ob**************@TK2MSFTNGP12.phx.gbl...
I am putting data from DataTable to treeView

foreach( DataRow aRow in aTable.Rows)
{
TreeNode tnode = new TreeNode(aRow[1].ToString() + aRow[2].ToString() +
" " + aRow[3].ToString());
treeView1.Nodes.Add(tnode);
//till here code works fine
//now I wanna add child nodes for last inserted node
foreach( DataRow GrupaRow in TabelaGrupe.Rows)
{
if(statment)
{
TreeNode tnodegr = new TreeNode(GrupaRow[2].ToString()
+ " " + GrupaRow[3].ToString());
//what should I write here to put node tnodegr as a child to last
inserted tnode
treeView1.Nodes.Add(tnodegr);//????
}
}
treeView1.ExpandAll();
}


Nov 16 '05 #4
A small change

foreach( DataRow aRow in aTable.Rows)
{
TreeNode tnode = new TreeNode(aRow[1].ToString() + aRow[2].ToString() +
" " + aRow[3].ToString());
//till here code works fine
//now I wanna add child nodes for last inserted node
foreach( DataRow GrupaRow in TabelaGrupe.Rows)
{
if(statment)
{
TreeNode tnodegr = new TreeNode(GrupaRow[2].ToString()
+ " " + GrupaRow[3].ToString());
tnode.Nodes.Add(tnodegr);
}
}
treeView1.Nodes.Add(tnode);
}
treeView1.ExpandAll();

"Chester Ragel" <CR****@Virtusa.com> wrote in message
news:eo**************@TK2MSFTNGP14.phx.gbl...
foreach( DataRow aRow in aTable.Rows)
{
TreeNode tnode = new TreeNode(aRow[1].ToString() + aRow[2].ToString() +
" " + aRow[3].ToString());
//till here code works fine
//now I wanna add child nodes for last inserted node
foreach( DataRow GrupaRow in TabelaGrupe.Rows)
{
if(statment)
{
TreeNode tnodegr = new TreeNode(GrupaRow[2].ToString()
+ " " + GrupaRow[3].ToString());
tnode.Nodes.Add(tnodegr);
treeView1.Nodes.Add(tnode);
}
}
treeView1.ExpandAll();
}
"Dino L." <se******@gmail.com> wrote in message
news:Ob**************@TK2MSFTNGP12.phx.gbl...
I am putting data from DataTable to treeView

foreach( DataRow aRow in aTable.Rows)
{
TreeNode tnode = new TreeNode(aRow[1].ToString() + aRow[2].ToString() +
" " + aRow[3].ToString());
treeView1.Nodes.Add(tnode);
//till here code works fine
//now I wanna add child nodes for last inserted node
foreach( DataRow GrupaRow in TabelaGrupe.Rows)
{
if(statment)
{
TreeNode tnodegr = new TreeNode(GrupaRow[2].ToString()
+ " " + GrupaRow[3].ToString());
//what should I write here to put node tnodegr as a child to last
inserted tnode
treeView1.Nodes.Add(tnodegr);//????
}
}
treeView1.ExpandAll();
}


Nov 16 '05 #5
thank you.

it works really good, just as I imagine
Nov 16 '05 #6
thank you.

it works really good, just as I imagine
Nov 16 '05 #7
can I add a search engine here?
how can I go from node to node and search ???
Nov 16 '05 #8
can I add a search engine here?
how can I go from node to node and search ???
Nov 16 '05 #9
You can use recursive search here easily like,

private void SearchNodes(TreeNode node)
{
foreach(TreeNode currentNode in node.Nodes)
{
//Do the search for the current node here
if((currentNode.Nodes!=null) && (currentNode.Nodes.Count>0))
{
SearchNodes(currentNode);
}
}
}

Call this methord from somewhere where you want to do the search and pass
the parent node there..

Chester.

"Dino L." <se******@gmail.com> wrote in message
news:u3**************@TK2MSFTNGP11.phx.gbl...
can I add a search engine here?
how can I go from node to node and search ???

Nov 16 '05 #10
You can use recursive search here easily like,

private void SearchNodes(TreeNode node)
{
foreach(TreeNode currentNode in node.Nodes)
{
//Do the search for the current node here
if((currentNode.Nodes!=null) && (currentNode.Nodes.Count>0))
{
SearchNodes(currentNode);
}
}
}

Call this methord from somewhere where you want to do the search and pass
the parent node there..

Chester.

"Dino L." <se******@gmail.com> wrote in message
news:u3**************@TK2MSFTNGP11.phx.gbl...
can I add a search engine here?
how can I go from node to node and search ???

Nov 16 '05 #11
thank you
there is your function now (with some changes)

private int SearchNodes(TreeNode node, string tekst)
{
int i = 0;
//added by dino :: string tekst is pattern match
try
{
foreach(TreeNode currentNode in node.Nodes)
{
//Do the search for the current node here
//added by dino :: must be >=0 or it want go trough lowest node level
if((currentNode.Nodes!=null) && (currentNode.Nodes.Count>=0))
{
if(currentNode.Text.StartsWith(tekst))
{
currentNode.Expand();
currentNode.BackColor = Color.Red;
i ++;
}
SearchNodes(currentNode,tekst);
//check :: does node match string???
}
}
}
Nov 16 '05 #12
thank you
there is your function now (with some changes)

private int SearchNodes(TreeNode node, string tekst)
{
int i = 0;
//added by dino :: string tekst is pattern match
try
{
foreach(TreeNode currentNode in node.Nodes)
{
//Do the search for the current node here
//added by dino :: must be >=0 or it want go trough lowest node level
if((currentNode.Nodes!=null) && (currentNode.Nodes.Count>=0))
{
if(currentNode.Text.StartsWith(tekst))
{
currentNode.Expand();
currentNode.BackColor = Color.Red;
i ++;
}
SearchNodes(currentNode,tekst);
//check :: does node match string???
}
}
}
Nov 16 '05 #13

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

Similar topics

0
by: Saradhi | last post by:
Hi All, Here I am facing a performance problem with the TreeView Node renaming. I am displaying a hierarchy Data in a treeview in my Windows C# Application. My tree view represents an...
0
by: Dino L. | last post by:
I am putting data from DataTable to treeView foreach( DataRow aRow in aTable.Rows) { TreeNode tnode = new TreeNode(aRow.ToString() + aRow.ToString() + " " + aRow.ToString());...
3
by: Saradhi | last post by:
Hi All, Here I am facing a performance problem with the TreeView Node renaming. I am displaying a hierarchy Data in a treeview in my Windows C# Application. My tree view represents an...
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 ..
2
by: Jack | last post by:
Hello, I am trying use a TreeView with checkboxes. I would like to check more than one node and allow all child nodes of selected nodes to be checked or unchecked with the parent is checked. ...
7
by: Ward Germonpré | last post by:
Hi, On a html page I have a Table called "resultaattbl", generated using dom- methods and an array of jsobjects. The rows below the columnheader have a class called "normaal". This is the...
2
by: Bob | last post by:
Hi, I would to have a tree view control with check boxes in which the parent and child nodes interacts, in the way that you normally see this occuring. Checking the parent node automatically...
0
by: divya1949 | last post by:
Create a windows c# application which will Read a xml file and populate nodes in the treeview. 1 On selection of treenode display the child nodes of that node in listview control 2. ...
2
by: Vajrala Narendra | last post by:
Hi, all am using asp.net 2.0, c# i have a tree view control from two tables i have to add nodes dynamically i hav category(cat_id,cat_name), sub category(sub_cat_id,cat_id,sub_cat_name) tables...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.