问题:怎样用TreeView显示指定的目录,点击TreeView的目录节点时,ListView显示TreeView目录中的文件?

解决方案 »

  1.   

    用数据库,在treeview的NODE的DATA 上记录ID,点击后,根据ID搜索数据库,在LISTVIEW里显示,我刚做过。
      

  2.   

    用 Findfirst 和 FindNext 函数找出文件夹中的所有文件。将它们添加到 ListView 中。
      

  3.   

    var yourdir,Yourpath:string;
        ASearchRec:TSearchRec;Yourpath='...';
    yourdir:=Yourpath+'\'+TreeView1.Selected.Text;
    if FindFirst(yourdir+'\*',faAnyFile,ASearchRec)=0 then
       Listview1.items.add.caption:=ASearchRec.Name;
    while( FindNext(ASearchRec)=0 )do
       Listview1.items.add.caption:=ASearchRec.Name;
    FindClose(ASearchRec);
      

  4.   

    将if FindFirst(yourdir+'\*',faAnyFile,ASearchRec)=0 then
    改为if FindFirst(Yourpath+'\'+yourdir+'\*',faAnyFile,ASearchRec)=0 then
      

  5.   

    有错误,TreeView没有显示指定的目录。
      

  6.   

    你不会打开win31面板上那两个控件地代码看看啊。都有。
      

  7.   

    如果你只是要显示目录的话建议你使用Samples下的ShellListView 和ShellTreeView
    如果不是的话用 htzq(想成为高手) 的方法;