Just depends on how you want to handle it. If transferring information to caller as node's text, you can do a search of all nodes to find it:
TreeNode FindTreeNodeText(TreeNodeCollection nodes, string findText)
{
TreeNode foundNode = null;
for (int i = 0; i < nodes.Count && foundNode == null; i++)
{
if (nodes[i].Text == findText)
{
foundNode = nodes[i];
break;
}
if (nodes[i].Nodes.Count > 0)
foundNode = FindTreeNodeText(nodes[i].Nodes, findText);
}
return foundNode;
}
If returning the selected node to the caller, you can select it directly:
void SelectNode(TreeNode node)
{
treeView1.SelectedNode = node;
}
and, to know which node is selected to return to caller:
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
TreeNode node = treeView1.SelectedNode;
}