是否可以禁用 OpenFileDialog 取消按钮?
是否可以设置OpenFileDialog的取消按钮enable = false?如果是这样,怎么办?
我正在使用 winform
编辑
OpenFileDialog file_open_dialog = new OpenFileDialog();
Is it possible to set the OpenFileDialog's cancel button enable = false? If so, How?
I'm using winforms
Edit
OpenFileDialog file_open_dialog = new OpenFileDialog();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不相信,而且有充分的理由!您确定要禁用“取消”按钮吗?由于这是一个模式对话框,这将阻止用户继续(从而使您的应用程序无法使用),直到他们选择一个文件 - 几乎肯定会出现这种情况根本不可能的情况,或者用户不这样做想要强制保存文件。
当然,我可能是错的,并且可能存在我不知道的完全合法的情况 - 但是我担心 Microsoft 也没有意识到这种情况,因此 OpenFileDialog 不支持禁用取消按钮。
恐怕如果您真的不想要取消按钮,您将需要创建自己的对话框克隆。
I don't believe so, and with good reason! Are you sure that you want to disable the Cancel button? Being that this is a modal dialog this would prevent the user from continuing (and hence making your application unusable) until they selected a file - there are almost certainly going to be scenarios where this simply isn't possible, or the user doesn't want to be forced into saving a file.
Of course I could be wrong and there could be a completely legit scenario that I'm not aware of - however I'm afraid that Microsoft were also unaware of this scenario and so the OpenFileDialog doesn't support disabling the cancel button.
I'm afraid that if you really don't want a cancel button you will need to create your own clone of the dialog.
如果需要的话,可以循环处理取消吗?可能会让用户感到沮丧;)
handle the cancel in a loop if you want? might frustrate users ;)