TreeView中如何返回一字符串所在的TTreeNode?如:
有一个节点的名字为 '我的程序',我要返加此节点的TTreeNode,有没有现成的方法或属性

解决方案 »

  1.   

    这个很好解决啊,把分都给我吧,哈哈
    具体问题,具体分析啊,看你要怎么得到这个接点的TTreeNode啊,如果是想单几得到的话,代码如下:
    //函算返回一个你在treeview1里单几得到的TTreeNode
    function TForm1.getNode:TTreeNode;   
    begin
      Result := TreeView1.Selected  
    end;如果是不要自己去选择,要程序去判断,代码如下:function TForm1.getNode:TTreeNode;
    var  
       thisnode : TTreeNode;
    begin
      thisnode := TreeView1.Items.GetFirstNode;
      while thisnode<>nil do
            begin
            if thisnode.text = '我的程序' then
               begin
                 Result := thisnode;//得到你要的TTreeNode;
                 break;
               end;
             thisnode := thisnode.getnode;
             end;
        Result := nil;
     end;