Deepa Sudhir

Deepa Sudhir

  • NA
  • 35
  • 21.2k

How to iterate through different node levels in a treeview

Mar 9 2015 4:05 AM

string parentnode,cnode,subchild;

foreach (TreeNode t in TreeViewArtMaterial.Nodes)

{

for (int iParent = 0; iParent < t.ChildNodes.Count; iParent++)

{

parentnode = t.ChildNodes[iParent].Text;

for (int iChild = 0; iChild < t.ChildNodes[iParent].ChildNodes.Count; iChild++)

{

cnode = t.ChildNodes[iParent].ChildNodes[iChild].Text;

for (int iChildChild = 0; iChildChild < t.ChildNodes[iParent].ChildNodes[iChild].Count; iChildChild++)

{

subchild = t.ChildNodes[iParent].ChildNodes[iChild].ChildNodes[iChildChild].Text;

}

}

}

}

Can u help me find the mistake? I need to iterate though the different nodes of a tree Can u help me out


Answers (1)