拖曳将文件从ListView拖放到Windows资源管理器? [英] Drag & Drop file from listview to windows explorer?

查看:60
本文介绍了拖曳将文件从ListView拖放到Windows资源管理器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在列表视图中列出了一堆文件,我想知道是否可以将文件拖放到Windows资源管理器?如果可以,怎么办?我似乎只找到相反的例子.谢谢!

I have a bunch of files listed within a listview, and I want to know is it possible to drag and drop the files to Windows Explorer? If so how? I only seem to find examples of the other way around. Thanks!

推荐答案

这就是我所做的.

首先,在您的列表视图中,为ItemDrag创建一个事件处理程序.

First off, in your listview, create an event handler for ItemDrag.

然后执行以下操作.

    private void listView_ItemDrag(object sender, ItemDragEventArgs e)
    {
        List<string> selection = new List<string>();

        foreach (ListViewItem item in listView.SelectedItems)
        {
            int imgIndex = item.ImageIndex;
            selection.Add(filenames[imgIndex]);
        }

        DataObject data = new DataObject(DataFormats.FileDrop, selection.ToArray());
        DoDragDrop(data, DragDropEffects.Copy);
    }

这篇关于拖曳将文件从ListView拖放到Windows资源管理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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