var List:TstringList; Node:Ttreenode;...
Node:=treeview1.item.item[0];
List:=TstringList.create;
List.Addobject('aaa',Node);现在我们可以通过 Ttreenode(list.object[list.indexof('aaa')] )   找到Node现在我们要怎么通过Node找到 List的'aaa'呢
问题由来:
仓库表: 仓库编号 int ,仓库名称 varchar(20)
一个treeview,它显示一个竖排的"仓库名称" (从仓库表中调出)
我要实现点击某一项treeview(仓库名称)就得知道这项的"仓库编号"是多少
本来可以通过"仓库名称"到表中查询相应的"仓库编号",可"仓库名称"是有重复的
因此我想利用Tstringlist存储每一项Treeview (就是List.AddObject(仓库编号),Node)
以后就可以通过Node得到仓库编号了
这是我的想法,现在实现不了
请大家帮忙,也可以说说其它的解决办法

解决方案 »

  1.   

    for i:=0 to List.count-1 do
    begin
      if List.object[i] = Node then
        result := List.Strings[i];
    end;
      

  2.   

    Aaa=^aa;
    aa=record
      仓库编号:string;
      仓库名称:string;
    end;
    可以使用node.Data存储一个结构指针也可以存储数据集的book
    var
    a:Aaa
    begin
    .....
    node.Data:=a;
    or
    node.data:=dataset.GetBook;
      

  3.   

    DataSet.GotoBook(node.data);//定位到记录