1
Answer

How to iterate through different node levels in a treeview

Ask a question

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)