¿Es posible hacer que uno de los nodos secundarios sea seleccionado programáticamente
Me gustaría seleccionar uno de los nodos secundarios de mi vista de árbol seleccionado programáticamente. Mi vista de árbol es la siguiente en tiempo de ejecución
Root
|->A.txt(I would like to select this node after doing some iteration in my application)
|->Child(Even if i select this node and do some operations i would like to select the above one only like that if n number of child nodes exists i would like to select the node that was with .txt extension)
He escrito el siguiente código, funciona bien, pero en un momento no puedo hacer esto, ¿alguien puede ayudar?
Este es mi codigo
if (tvwACH.Nodes.Count != 0)
{
// tvwACH.ExpandAll();
TreeNode tn;
tn = tvwACH.Nodes[0];
tvwACH.ExpandAll();
if (tn.Nodes.Count != 0)
{
tn = tn.Nodes[0];
}
if (tn.Tag.ToString() == "3")
{
if (tvwACH.SelectedNode.Parent != null)
{
tn.Parent.Expand();
tvwACH.SelectedNode = tn;
}
}
}
Mi vista de árbol final es la siguiente
Root
|->Some.txt
|->Child
|->Sub Child
|->Child (for subchild) // After this i will not have any nodes so my code works up to Sub Child but if i added some thing after clicking Child after subchild i am unable to select the node i meeded as it has no nodes can any one help me out please