aspx treenode 递归遍历当前节点找下一个节点的错误,找到就停
private void pastNode(TreeNode currentNode){
TreeNode tn = TreeView1.SelectedNode;
TreeNode ftn = TreeView1.SelectedNode.Parent;
int index = ftn.ChildNodes.IndexOf(tn);
if (currentNode.ChildNodes.Count > 0)
{
foreach (TreeNode node in currentNode.ChildNodes)
{
pastNode(node);
}
}
else
{
if (getText(currentNode.Value,3)=="0")
{
currentNode.Selected = true;
currentNode.Select();
return;
}else
{
if (index + 1 >= 0)
{
foreach (TreeNode node in currentNode.Parent.ChildNodes[index + 1].Parent.ChildNodes)
{
pastNode(node);
}
}
}
}
}
大神们,看看哪错了。。找到错误循环不停止。。 --------------------编程问答-------------------- private bool pastNode(TreeNode currentNode)
{
TreeNode tn = TreeView1.SelectedNode;
TreeNode ftn = TreeView1.SelectedNode.Parent;
int index = ftn.ChildNodes.IndexOf(tn);
if (currentNode.ChildNodes.Count > 0)
{
foreach (TreeNode node in currentNode.ChildNodes)
{
if(pastNode(node)) return;
}
}
else
{
if (getText(currentNode.Value,3)=="0")
{
currentNode.Selected = true;
currentNode.Select();
return;
}else
{
if (index + 1 >= 0)
{
foreach (TreeNode node in currentNode.Parent.ChildNodes[index + 1].Parent.ChildNodes)
{
if(pastNode(node)) return;
}
}
}
}
} --------------------编程问答-------------------- 少写两个地方
private bool pastNode(TreeNode currentNode)
{
TreeNode tn = TreeView1.SelectedNode;
TreeNode ftn = TreeView1.SelectedNode.Parent;
int index = ftn.ChildNodes.IndexOf(tn);
if (currentNode.ChildNodes.Count > 0)
{
foreach (TreeNode node in currentNode.ChildNodes)
{
if(pastNode(node)) return;
}
}
else
{
if (getText(currentNode.Value,3)=="0")
{
currentNode.Selected = true;
currentNode.Select();
return true;
}else
{
if (index + 1 >= 0)
{
foreach (TreeNode node in currentNode.Parent.ChildNodes[index + 1].Parent.ChildNodes)
{
if(pastNode(node)) return;
}
}
}
}
return false;
} --------------------编程问答--------------------
+1
补充:.NET技术 , ASP.NET