拖动TreeView上的文件夹在ListView中显示文件解决办法
拖动TreeView上的文件夹在ListView中显示文件
有两个treeview控件和一个ListView控件,暂且记tvA、tvB和lvC吧,从tvA中拖动文件夹到tvB中,然后将拖动文件夹中的所有文件显示在lvC中
tvA显示某路径下的所有文件,tvB是某项目分组,从tvA中拖动文件夹到tvB中时将拖动文件夹中的所有文件(非文件夹)显示到lvC中;tvA和tvB之前的拖动可以实现,关键是一旦拖动到tvB中后如何将拖动文件夹中所有的文件获取到。
希望各位大侠指点下 ^^
------解决方案--------------------
楼主,你要实现这样几个功能
1.拖拽功能
2.根据文件夹遍历所有文件
拖拽功能
有两个treeview控件和一个ListView控件,暂且记tvA、tvB和lvC吧,从tvA中拖动文件夹到tvB中,然后将拖动文件夹中的所有文件显示在lvC中
tvA显示某路径下的所有文件,tvB是某项目分组,从tvA中拖动文件夹到tvB中时将拖动文件夹中的所有文件(非文件夹)显示到lvC中;tvA和tvB之前的拖动可以实现,关键是一旦拖动到tvB中后如何将拖动文件夹中所有的文件获取到。
希望各位大侠指点下 ^^
------解决方案--------------------
楼主,你要实现这样几个功能
1.拖拽功能
2.根据文件夹遍历所有文件
拖拽功能
- Delphi(Pascal) code
将treeview的dragmode设置为dmAutomatic 在 procedure TForm.TreeViewDragOver事件中谁便写点什么。 procedure TForm.TreeViewDragDrop(Sender, Source: TObject; X, Y: Integer); var VL_Node, VL_tmpNode: TTreeNode; VL_I: integer; begin if (TreeView.Selected <> nil) and (TreeView.Selected.level > 0) then begin VL_Node := TreeView.GetNodeAt(X, Y); if VL_Node <> nil then begin if TreeView.Selected.Parent = VL_Node then Exit; if TreeView.Selected = VL_Node then Exit; if TreeView.Selected.Level < VL_Node.Level then begin VL_tmpNode := VL_Node; for VL_I := 0 to VL_Node.Level - TreeView.Selected.Level - 1 do begin VL_tmpNode := VL_tmpNode.Parent; end; if TreeView.Selected = VL_tmpNode then Exit; end; if Application.MessageBox('是否确认要移动该节点?', '确认信息', mb_YESNO or mb_ICONQUESTION) <> IDYES then Exit; TreeView.Selected.MoveTo(VL_Node, naADDChild); end; end; end;