如何创建类似资源管理器的文件夹浏览器控件

如何创建类似资源管理器的文件夹浏览器控件

本文介绍了如何创建类似资源管理器的文件夹浏览器控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 VS2008 中使用 C# 和 WinForms,我想创建一个文件浏览器控件,它的外观和行为类似于 Windows 资源管理器中的左窗格.令我惊讶的是,默认情况下,.NET 没有提供这样的控件.

Using C# and WinForms in VS2008, I want to create a file browser control that looks and acts like the left pane in Windows Explorer. To my astonishment, such a control does not ship with .NET by default.

理想情况下,我希望其内容与资源管理器中的完全相同.例如,在 Windows 7 上,它应该显示收藏夹和库伪文件夹.当然,如果可以的话,我不想专门为每个版本的 Windows 编写代码.

Ideally, I would like its contents to be exactly the same as in Explorer. For example, on Windows 7, it should show the Favorites and Libraries pseudo-folders. Of course, I do not want to code specifically for each version of Windows if I can help it.

我已经浏览过,并且有一些此类控件的示例,但它们都是手工制作的,因此与 Explorer 中的控件无法 100% 相同.

I have browsed around, and there are some examples of such controls, but they are all hand-rolled and therefore won't work 100% the same as the one in Explorer.

有什么办法可以简单地重用资源管理器控件吗?或者,如果没有,访问将显示的项目树?

Is there any way I can simply reuse the Explorer control instead? Or, if not, to get access to a tree of the items that it would show?

推荐答案

Microsoft 提供 在 C# 中创建 Windows 资源管理器样式界面的演练.

Microsoft provides a walkthrough for creating a Windows Explorer style interface in C#.

代码项目 和其他网站上也有一些示例.直接示例是 Explorer Tree我的资源管理器文件浏览器高级文件资源管理器其他.Explorer Tree 从我短暂的一瞥中看起来是最好的.

There are also several examples on Code Project and other sites. Immediate examples are Explorer Tree, My Explorer, File Browser and Advanced File Explorer but there are others. Explorer Tree seems to look the best from the brief glance I took.

我在 Google 中使用搜索词 windows explorer tree view C# 来查找这些链接.

I used the search term windows explorer tree view C# in Google to find these links.

这篇关于如何创建类似资源管理器的文件夹浏览器控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 07:21