private TreeNode GetNode(TreeNode node, string strValue)
{
if (node.Text == strValue)
{
return node;
}
TreeNode targetNode = null;
foreach (TreeNode subNode in node.ChildNodes)
{
targetNode = GetNode(subNode, strValue);
if (targetNode != null)
{
break;
}
}
return targetNode;
}
调用:{
if (node.Text == strValue)
{
return node;
}
TreeNode targetNode = null;
foreach (TreeNode subNode in node.ChildNodes)
{
targetNode = GetNode(subNode, strValue);
if (targetNode != null)
{
break;
}
}
return targetNode;
}
TreeNode node = null;
foreach (TreeNode tn in this.TreeView1.Nodes)
{
node = this.GetNode(tn, "yourValue");
if (node != null)
{
break;
}
}