
要求是用户应该能够从他们的pendrive或网络中浏览和选择特定文件,而不能从系统驱动器上的任何位置浏览和选择特定文件.所以我正在寻找一种解决方案,以某种方式隐藏标准OpenfileDialog窗口上的链接和按钮,因此如果有任何网络位置链接,用户只会看到他们的pendrives.
我也在MSDN和其他论坛上搜索过,直到现在我才发现任何想法.如果没有办法使用标准的OpenfileDialog工作,是否有任何简单的自定义组件用于浏览限制在指定驱动器或父文件夹的文件?
解决方法 在这里,它就像 Customizing Your Open File Dialog一样简单The OpenfileDialog class exposes a set of propertIEs to configure the
dialog. For example,you can choose the initial directory,the initial
filter index,the Title of the window,whether multiple files can be
selected,and whether the application’s current directory should be
restored before closing. The class also fires an event (called fileOk)
whenever the user clicks on the Open button.OpenfileDialog is a sealed class,so you can’t derive from it.
However,if you want to customize the behavior of a file dialog,to
the extent that it is possible,you should create a brand new class
deriving from the abstract class fileDialog. In this case,you have
access to a couple of powerful but protected methods such as HookProc
and RunDialog. HookProc defines the dialog Box hook procedure that
adds specific functionality to the common dialog….
更新:
在windows 7 PC上它不起作用.例如:
OpenDialogPlaces o = new OpenDialogPlaces();//o.Places.Add(18);//o.Places.Add(5);//o.Places.Add(6);o.Init();o.OpenDialog.ShowDialog();o.reset();
仍然显示左手的一切:
它在以前的windows版本中有效:
另一件事似乎是微软已经改变了ComDlg32的位置,我尝试了两个地方但没有运气.
总结以上是内存溢出为你收集整理的c# – 如何在OpenFileDialog窗口中隐藏功能和可选文件夹/驱动器?全部内容,希望文章能够帮你解决c# – 如何在OpenFileDialog窗口中隐藏功能和可选文件夹/驱动器?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)