如何拖动listview项并在Windows资源管理器或树视图控件中删除。 [英] How to Drag listview items and drop either in Windows explorer or treeview control.

查看:68
本文介绍了如何拖动listview项并在Windows资源管理器或树视图控件中删除。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我需要关于拖放的帮助。

我的场景是我有不同类型的文件的列表视图,如TXT,doc,img等。

我需要实现我的listview上的拖放功能。就像用户可以从listview中拖动项目,他可以在应用程序的Windows资源管理器或树视图控件中删除它。

当项目被删除到Windows资源管理器时,应该下载该文件。如果用户将该文件删除到树视图,那么该文件将被移动到树视图的选定节点。

我的问题是,在项目拖动事件中,当用户尝试将文件放在树视图上时,数据应该是在DoDragDrop方法中作为listview项发送,当用户下载到资源管理器时,我在temp文件夹中创建文件,然后将路径发送到DoDragDrop方法。

那么我该如何替代地执行此任务。 div class =h2_lin>解决方案

为什么要为这个简单的任务创建临时文件而不是这个,你可以尝试文件复制方法,如下所示。



 System.IO.File.Copy(  SourcePath  DestinationPath); 





谢谢&问候

Anand。 G


在此链接中找到解决方案。

好​​文章



http://blogs.msdn.com/b/delay/archive/2009/10/26/creating-something-from-nothing-developer-friendly-virtual-file-implementation-for-net.aspx?CommentPosted = true#commentmessage [ ^ ]


Hi i need help on drag drop.
My scenario is i have listview with different type of files like TXT, doc, img etc.
I need to implement drag and drop functionality on my listview. Like user can drag item from listview and he can drop it either in windows explorer or treeview control on the application.
When the item is dropped to windows explorer then that file should be downloaded. If user drop that file to treeview then that file is moved to the selected node of the treeview.
My problem is, in item drag event when the user tries to drop the file on treeview then data should se sent as listview item in DoDragDrop method, and when user drops to the explorer then i am creating file in temp folder and then sending the path to DoDragDrop Method.
So how can i do this task alternatively.

解决方案

Why your are creating temporary files for this simple task instead of this you can try file copying method as follows.

System.IO.File.Copy("SourcePath","DestinationPath");



Thanks & Regards
Anand. G


Found solution here in this link.
Nice article

http://blogs.msdn.com/b/delay/archive/2009/10/26/creating-something-from-nothing-developer-friendly-virtual-file-implementation-for-net.aspx?CommentPosted=true#commentmessage[^]


这篇关于如何拖动listview项并在Windows资源管理器或树视图控件中删除。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆