2

你知道如何创建 listView 的任何好例子,它看起来和 Windows 资源管理器具有相同的方法。

复制,粘贴,显示缩略图??

我必须使用 listView 因为我不能允许用户更改目录,并且我不能在 Windows 资源管理器中禁用此选项(我的意思是我可以单击向上或向下或放置路径的地方。

4

4 回答 4

2

我一直在推荐这个项目,从来没有听到过抱怨。请注意,自 Vista 以来可使用嵌入式浏览器,它由Windows API 代码包中的 ExplorerBrowser 类包装。

请注意,这些解决方案会将大量依赖项放入您的项目中。如果您不喜欢该路径,请考虑权衡该成本与简单实现 OpenFileDialog 的FileOk 事件并取消单击 OK 按钮。

于 2010-03-11T13:16:39.177 回答
1

这不是一项简单的任务,但你可以看看这个项目。它在 VB.Net 中,但它可以作为灵感的来源。

于 2010-03-11T09:21:49.683 回答
1

我写了一些东西,但我不知道如何在单击图标时添加事件以获取该图标的路径。

    path = folderBrowserDialog1.SelectedPath;


ImageList imageList1 = new ImageList();
imageList1.ImageSize = new Size(256, 256);
imageList1.ColorDepth = ColorDepth.Depth24Bit;
string[] iconFiles = Directory.GetFiles(path, "*.jpg");

foreach (string iconFile in iconFiles)
{
   try
   {
      imageList1.Images.Add(Image.FromFile(iconFile));
   }
   catch
   {
         MessageBox("Error","");
   }
}

this.listView1.View = View.LargeIcon;
this.listView1.LargeImageList = imageList1;

for (int j = 0; j < imageList1.Images.Count; j++)
{
    ListViewItem item = new ListViewItem();

    item.ImageIndex = j;   
    this.listView1.Items.Add(item);               
}

如何重建此代码?

于 2010-03-11T09:38:29.677 回答
0

您可以使用 Graphics.DrawImage 加载 jog 文件并从中创建缩略图。这仅适用于图像文件。

要获取其他文件类型的缩略图,您必须使用 shell IExtractIcon 接口。

对于复制/粘贴,请使用带有文件完整路径的 DataFormats.FileDrop 格式。


对于现成的替代方案,请参阅我们的FileView控件。

于 2010-03-11T11:41:38.227 回答