要求:在treeview展开中的每一个item中,需要带一个id参数,当选中此item时,将此id参数读出,作为其他用。
提问:将id参数带入相应的item中,然后选中此item时将id读出来.

解决方案 »

  1.   

    id是整型吗?item.Data := Pointer(id);id := Integer(TreeView1.Selected.Data);
      

  2.   

    先声明一指针
    type
        Pmycode=^Tmycode;
        Tmycode=record
            da:string;
    end;写数据:
    new(MyCode);
    Mycode^.da:=Query1.FieldByName('id').AsString;
    treers.Items.AddChildobject(t0,cbm+'  '+fieldbyname('name').AsString,mycode);读数据
    id:=pMycode(treers.Selected.Data)^.da
      

  3.   

    同意 sysu. 即使 id 不是 Integer类型,是一个记录同样可以用上面的方法只是需要确保内存在 Item 被删除时释放,防止内存泄漏。
      

  4.   

    最好是在treeview动态生成时,每生成一个item,就将对应的id保存在内存中,