有没有办法自定义 OpenFileDialog 以选择文件夹而不是文件?
我有一个 VB/C# .NET 2.0 项目,如果可能的话,我想自定义 OpenFileDialog 框以选择目录而不是文件。这样做的原因是因为FolderBrowserDialog 很丑陋,并且对于我的大多数用户来说导航使用起来很痛苦。
我知道如何使用 OpenFileDialog 过滤扩展名,但是我可以设置一个标志或变量来仅显示目录并选择 .NET 中内置的目录吗?如果没有,那么可以使用什么好的第三方对话框/如果我要创建自己的对话框,我应该从哪里开始?
抱歉,我没有太多创建前端的经验。对此的任何帮助或指导将不胜感激:)
I have a VB/C# .NET 2.0 project that, if possible, I would like to customize the OpenFileDialog box to select a directory rather than a file. The reason for this is because the FolderBrowserDialog is ugly and a pain for most of my users to navigate using.
I know how to filter extensions using OpenFileDialog, but is there a flag or variable I can set that will allow me to only show directories and select those directories that is built into .NET? And if not, what is a good third party dialog to use/where should I begin if I am to create my own?
I apologize, I do not have much experience creating frontends. Any help or direction on this would be greatly appreciated :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在检查了Mayank发布的问题后,我发现.NET 中没有本地方法可以做到这一点。然而,Scott Wisniewski 的一篇文章给出了我正在寻找的东西。
要在 .NET 2.0 中实现此功能,我唯一要做的就是将以下代码添加到我的项目中名为 ExtensionAttribute.cs 的文件中。在 .NET 3.5+ 中不需要此方法,但请注意,据报道这根本不适用于 Visual Studio 2005。
同样,此代码片段仅适用于 Visual Studio 2008,不适用于 VS 2005。
After checking the question that Mayank posted, I found out that there is no native way to do this in .NET. However, one of the posts by Scott Wisniewski yielded the exactly what I was looking for.
The only thing I had to do to make this work in .NET 2.0 was add the following code to my project in a file called ExtensionAttribute.cs. This method is not needed in .NET 3.5+, but please note that this is reported to not work at all with Visual Studio 2005.
Again, this code snippet only works with Visual Studio 2008, it will not work with VS 2005.