Is it possible to get one of the child node get selected programatically

前端 未结 1 1472
天涯浪人
天涯浪人 2021-01-28 14:37

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 wo         


        
相关标签:
1条回答
  • 2021-01-28 15:23

    Atlast i got the answer

            TreeNode TvNode = tvwACH.SelectedNode.Parent;
    
                while (TvNode != null)
                {
                    if (TvNode.Text.EndsWith(".txt", true, System.Globalization.CultureInfo.InvariantCulture))
                    {
                        tvwACH.SelectedNode = TvNode;
                        TvNode = null;
                    }
                    else
                        TvNode = TvNode.Parent;
                }                      
    
    0 讨论(0)
提交回复
热议问题