是否可以禁用 OpenFileDialog 取消按钮?

发布于 2024-09-27 17:15:34 字数 200 浏览 3 评论 0原文

是否可以设置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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

智商已欠费 2024-10-04 17:15:34

我不相信,而且有充分的理由!您确定要禁用“取消”按钮吗?由于这是一个模式对话框,这将阻止用户继续(从而使您的应用程序无法使用),直到他们选择一个文件 - 几乎肯定会出现这种情况根本不可能的情况,或者用户不这样做想要强制保存文件。

当然,我可能是错的,并且可能存在我不知道的完全合法的情况 - 但是我担心 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.

吻安 2024-10-04 17:15:34

如果需要的话,可以循环处理取消吗?可能会让用户感到沮丧;)

do
  {}
while (openFileDialog1.ShowDialog() != DialogResult.OK);

handle the cancel in a loop if you want? might frustrate users ;)

do
  {}
while (openFileDialog1.ShowDialog() != DialogResult.OK);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文