You should do this using recursion.. it become much simpler
bool Select_It(string str, TreeView tvwParent, TreeNode tN)
{
if (tN.Text == str)
{ tvwParent.SelectedNode = tN; return true; }
foreach (TreeNode child in tN.Nodes)
{
if (Select_It(str, tvwParent, tN)) { return true; }
}
return false;
}
bool Select_It_By_Tag_Value(string str, TreeView tvwParent, TreeNode tN)
{
if (tN.Tag.ToString() == str)
{ tvwParent.SelectedNode = tN; return true; }
foreach (TreeNode child in tN.Nodes)
{
if (Select_It(str, tvwParent, tN)) { return true; }
}
return false;
}
void select_node()
{
if (Select_It_By_Tag_Value("3", tvwACH, tvwACH.Nodes[0]))
{
}
else
{
}
}