“否”和“否”之间的区别和“取消”在消息框按钮中

发布于 2024-12-01 13:33:17 字数 164 浏览 1 评论 0原文

当用户要删除项目时,我使用 MessageBox 显示确认消息,最初使用 MessageBoxButtons.YesNoCancel。后来我把它改成了 YesNo,因为有用户指出,在这种情况下,“否”和“取消”没有真正的区别。我的问题是...有什么区别?是否有理由使用 YesNoCancel 而不是 YesNo?

I was using a MessageBox to show a confirmation message when the user goes to delete an item and initially used MessageBoxButtons.YesNoCancel. Later I changed it to YesNo instead because a user pointed out that there was no real difference in "No" and "Cancel" in this case. My question is...what is the difference? Is there ever a reason to use YesNoCancel instead of YesNo?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(6

記柔刀 2024-12-08 13:33:17

就您而言,没有什么区别,因为您的问题仅导致一项操作,然后完成。

在标准用法中,“是否取消”通常会问一个问题,“是”或“否”将选择不同的操作,然后继续执行另一个操作(例如退出表单),“取消”将放弃所有操作。

例如:退出Word,是否要保存? “是,否,取消”。是和否将继续退出,无论是否保存,取消将不保存或退出。

无论你做什么,都要确保“取消”能够满足用户最期望的效果——当我必须专注于其他事情时,如果收到消息框轰炸,我永远都会收到垃圾取消邮件。如果我取消某件事,我不想失去很多工作,因为我没有时间停下来正确处理它。

用户滥用取消:-)

In your case there is no difference as your question results in just one action and then finishes.

In standard usage, the Yes No Cancel usually asks a question, Yes or No will chose a different action and then proceed to do yet another action (like quitting a form), Cancel will abandon all actions.

For example: quitting Word, do you wish to save? "Yes, No, Cancel". Yes and No will continue to quit with or without saving, cancel will not save or quit.

Whatever you do, make sure Cancel does what the user expects most - I forever spam cancel if bombarded with message boxes when I have got to focus on something else. If I cancel something I don't want to lose a lot of work because I didn't have time to stop and handle it properly.

Users abuse cancel :-)

随梦而飞# 2024-12-08 13:33:17

当然可能有。例如,如果有一个保存对话框,并且您输入了一个已存在的文件名,该对话框可能会询问您是否要覆盖该文件。

是意味着覆盖该文件。否可能意味着在文件名末尾附加“(1)”,或提示输入不同的文件名。取消可能意味着最终不保存。

您应该注意,YesNoCancel 都是不同的枚举,并且不具有相同的值,因此您可以区别对待它们。

请记住无论如何都要处理取消,因为如果用户单击对话框屏幕右上角的 x 按钮,则 ShowDialog() 的结果是 DialogResult.Cancel

Sure there could be. For example, if there is a save dialog and you enter a filename that already exists, the dialog could ask you if you want to overwrite the file.

Yes would mean overwrite the file. No might mean append a "(1)" at the end of the file name, or prompt for a different file name. Cancel might mean don't save after-all.

You should note that Yes, No, and Cancel are all different enums and do not have the same value, so you can treat them differently.

REMEMBER TO HANDLE CANCEL ANYWAY because if the user clicks the x button in the top right corner of your dialog screen, the result of ShowDialog() is DialogResult.Cancel!

猫性小仙女 2024-12-08 13:33:17

以下是 YesNoCancel 何时适用的示例:

“您想在退出之前保存更改吗?”

  • 是 - 保存并退出
  • 否 - 不保存并退出
  • 取消 - 我意外按下了按钮,不要退出。

Here's an example of when YesNoCancel would be appropriate:

"Would you like to save your changes before quitting?"

  • Yes - Save and quit
  • No - Don't save and quit
  • Cancel - I pressed the button on accident, don't quit.
你曾走过我的故事 2024-12-08 13:33:17

我确信很容易想出一个场景,其中“否”作为响应和“取消”之间存在语义差异。传统上,“取消”应该使程序返回到开始当前一系列操作之前的状态。 “不”当然没有同样的规则。

例子:

“您要删除 10 个文件中的第 4 个吗?”
是:删除文件
否:不要删除该文件,继续处理第 5 个文件(共 10 个)
取消:退出本次操作,回到未删除任何文件的状态。

Im sure its easy enough to come up with a scenario where there would be a symantic difference between "No" as a response and "Cancel". Traditionally "Cancel" should return the program to its state before starting the current series of operations. "No" certainly doesnt have this same rule.

Example:

"Do you wish to delete file 4 of 10?"
Yes: Delete the file
No: Dont delete the file, move on to file 5 of 10
Cancel: Exit this operation and return to having not deleted any files.

倒数 2024-12-08 13:33:17

我猜“取消”用于中止整个操作。如果您正在处理一个巨大的过程,例如,将一组文件从一个目录移动到另一个目录,您可能想向用户询问有关特定文件的信息 - 例如,确认用户是否确实想要移动某个目录受保护的文件。如果用户按“否”,您将忽略该项目并继续操作。如果用户按“取消”,您将中止整个操作(并且可能回滚之前的操作)。

当然,对于小程序或者简单的情况,“取消”和“否”没有区别。

I guess "Cancel" is used to abort the whole operation. If you are dealing with a huge procedure, for example, moving a set of files from one directory to another, you may want to ask something to the user about a specific file - for instance, to confirm if the user really wants to move a protected file. If the user presses "No", you ignore that item and continue the action. If the user presses "Cancel", you abort the whole action (and, maybe, rollback the previous action).

Of course, for a small procedure or a simple situation, "Cancel" and "No" have no difference.

木有鱼丸 2024-12-08 13:33:17

下面是一个示例:

假设您正在退出带有未保存文件的应用程序,例如文字处理程序。

退出时会出现一条确认消息:“您的文件有尚未保存的更改。您想保存它们吗?”

在这种情况下:

是 = 保存文件并退出

否 = 退出并丢失更改

取消 = 中止退出并返回到应用程序

Here's an example:

Say you are exiting an application with an unsaved file, like a word processor.

There is a confirmation when exiting that says: "Your file has changes that haven't been saved. Would you like to save them?"

In this case:

Yes = save the file and exit

No = exit and lose the changes

Cancel = abort the exit and go back to the application

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