Hi all, I would like to select one of the child node of my treeview get selected programatically. My treeview is as follow at run time
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)
I have written the following code it works fine but at one point i am unable to do this can any one help
This is my code
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;
}
}
}
My final treeview is as follows
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