private FindNodeInTreeAtPath ( TreeView tree, string path ) : TreeNode | ||
tree | TreeView | |
path | string | |
Результат | TreeNode |
private TreeNode FindNodeInTreeAtPath(TreeView tree, string path)
{
string[] subnodes = path.Split(new string[] { tree.PathSeparator }, StringSplitOptions.None);
TreeNodeCollection searchNodes = tree.Nodes;
TreeNode currentNode = null;
foreach (string search in subnodes) {
bool found = false;
foreach (TreeNode tn in searchNodes) {
if (tn.Name == search) {
found = true;
currentNode = tn;
searchNodes = tn.Nodes;
break;
}
}
if (!found) {
currentNode = null;
break;
}
}
return currentNode;
}