在一棵树中,我知道一个结点的Text值,我怎么才能得这个结点,不用循环的

解决方案 »

  1.   

    //搜索树节点
    procedure Tfrm_PM_BoundConfig.Act_lookupExecute(Sender: TObject);
    var
      i:integer;
      Find_Flag:Boolean;
      s_temp:string;
    begin
      if (UserPopedomMenuEnabled(250201)) then
      begin
        Application.MessageBox('对不起,您没有执行该操作的权利','系统提示',MB_OK+MB_ICONWARNING);
        exit;
      end;
      Find_Flag:=false;
      if Trim(cxT_lookupTree.Text)='' then
      begin
        application.MessageBox('查询条件不能为空!','系统提示',MB_OK+MB_ICONWARNING);
        exit;
      end
      else
      begin
        s_temp:=Trim(cxT_lookupTree.Text);
        suiTV_values.SetFocus;
        for i:=0 to suiTV_values.Items.Count-1 do
        begin
          if pos(s_temp,suiTV_values.Items[i].Text)>0 then
          begin
            suiTV_values.Items[i].Selected:=true;
            suiTV_values.FindNextToSelect;        suiTV_values.OnClick(self);                                        //获得单击事件        Find_Flag:=true;                                                     //判断是否一次找到结点
            if Application.MessageBox('是否继续查找','系统提示',MB_YESNO)=mryes then
            begin
              Continue;
            end
            else
            begin
              break;
            end;
          end;
        end;
        if not Find_Flag then
          application.MessageBox(PChar(Format('没有找到  [%s]  ',[s_temp])),'系统提示',MB_OK+MB_ICONWARNING);
      end;
    end;
      

  2.   

    TO: flyman307() 你好像是用的循环吧,不过也谢了
    我也是用循环实现的
      

  3.   

    不用循环也能实现
    先把TreeView1的信息读出来再操作
    TreeView1.SaveToStream();
    ....
      

  4.   

    楼上的大哥,把你的程序发给我看看,让我学习学习ListView和TreeView的用法,谢谢~~~
    [email protected]