我使用的是Win表单树视图类。我需要有可能通过其fullpath属性导航到指定的节点。例如,我有一个完整的路径("countryregion1city2"),并希望通过这个路径自动选择这个节点。有人能帮我吗?
这是msdn的树视图导航
private void PrintRecursive(TreeNode treeNode)
{
// Print the node.
System.Diagnostics.Debug.WriteLine(treeNode.Text);
MessageBox.Show(treeNode.Text);
// Print each node recursively.
foreach (TreeNode tn in treeNode.Nodes)
{
PrintRecursive(tn);
}
}
// Call the procedure using the TreeView.
private void CallRecursive(TreeView treeView)
{
// Print each node recursively.
TreeNodeCollection nodes = treeView.Nodes;
foreach (TreeNode n in nodes)
{
PrintRecursive(n);
}
}
这对你也有帮助带树视图导航的资源管理器的Codeproject变体