MessageBoxResult 枚举

定义

指定用户单击的消息框按钮。 MessageBoxResultShow 方法返回。MessageBoxResult is returned by the Show method.

public enum class MessageBoxResult
public enum MessageBoxResult
type MessageBoxResult = 
Public Enum MessageBoxResult
继承
MessageBoxResult

字段

Cancel 2

消息框的结果值为“取消”。The result value of the message box is Cancel.

No 7

消息框的结果值为“否”。The result value of the message box is No.

None 0

消息框未返回值。The message box returns no result.

OK 1

消息框的结果值为“确定”。The result value of the message box is OK.

Yes 6

消息框的结果值为“是”。The result value of the message box is Yes.

示例

有关详细信息, 请参阅MessageBox 示例For more information, see MessageBox Sample.

注解

Show返回一个MessageBoxResult值, 该值指定用户在消息框上单击的按钮。Show returns a MessageBoxResult value that specifies which button on a message box a user clicked. MessageBoxButton指定在消息框中显示哪些按钮。MessageBoxButton specifies which buttons are displayed on a message box.

消息框返回的结果值取决于消息框具有哪些按钮, 以及用户如何关闭消息框:The result value that is returned from a message box depends on what buttons the message box has and how a user closes a message box:

  • 在具有 "确定" 按钮的消息框上, 如果用户单击 "确定" 按钮, 单击标题栏中的 "关闭" 按钮或按ESC键, 则会返回 "ok"。On a message box that has an OK button, OK is returned if a user clicks the OK button, clicks the Close button in the title bar, or presses the ESC key.

  • 在具有 "确定" 按钮和 "取消" 按钮的消息框上, 如果用户单击 "确定" 按钮, 则返回 "ok"。On a message box that has an OK button and a Cancel button, OK is returned if a user clicks the OK button. 如果用户单击 "取消" 按钮或标题栏中的 "关闭" 按钮, 则返回 "取消"。If a user clicks the Cancel button or the Close button in the title bar, Cancel is returned.

  • 在具有 "是" 按钮和 "" 按钮的消息框中, 将禁用标题栏中的 "关闭" 按钮。On a message box that has a Yes button and a No button, the Close button in the title bar is disabled. 因此, 如果用户单击 "是" 按钮, 则返回 "是"; 如果用户单击 "" 按钮, 则返回 "否"。Consequently, Yes is returned if a user clicks the Yes button, and No is returned if a user clicks the No button.

  • 当单击 "是" 按钮、 "" 按钮和 "取消" 按钮时, 如果单击 "" 按钮, 则返回 "是"; 如果单击 "" 按钮, 则返回 "否"。On a message box that has a Yes button, a No button, and a Cancel button, Yes is returned if the Yes button is clicked and No is returned if the No button is clicked. 如果用户单击 "取消" 按钮或标题栏中的 "关闭" 按钮, 则返回 "取消"。If a user clicks the Cancel button or the Close button in the title bar, Cancel is returned.

适用于

另请参阅