MessageBoxButton 枚举

定义

指定显示在消息框上的按钮。 用作 Show 方法的参数。Used as an argument of the Show method.

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

字段

OK 0

消息框显示“确定”按钮。The message box displays an OK button.

OKCancel 1

消息框显示“确定”和“取消”按钮。The message box displays OK and Cancel buttons.

YesNo 4

消息框显示“是”和“否”按钮。The message box displays Yes and No buttons.

YesNoCancel 3

消息框显示“是”、“否”和“取消”按钮。The message box displays Yes, No, and Cancel buttons.

示例

有关详细信息, 请参阅 GitHub 上的MessageBox 示例For more information, see the MessageBox Sample on GitHub.

注解

默认情况下, MessageBox.Show该方法将显示一个具有 "确定" 按钮的消息框。By default, the MessageBox.Show method displays a message box that has an OK button. MessageBox.Show您可以使用// 接受参数的方法的重载来指定不同的按钮组合, 其中包括 "确定"、"确定"、"是"、"否" MessageBoxButton , 而 "是"//取消You can use overloads of the MessageBox.Show method that accept a MessageBoxButton argument in order to specify different combinations of buttons, which include OK, OK/Cancel, Yes/No, and Yes/No/Cancel.

用户单击的按钮的值由MessageBox.Show返回, 且是MessageBoxResult枚举值之一。The value of the button that a user clicks is returned by MessageBox.Show and is one of the values of the MessageBoxResult enumeration.

如果指定YesNo, 则禁用消息框标题栏中的 "关闭" 按钮。If you specify YesNo, you disable the Close button in the message box title bar. 但是, 对于所有其他选项, 将启用 "关闭" 按钮。However, the Close button is enabled for all other options. 当用户单击 "关闭" 按钮或按ESC键时, 消息框将返回消息框MessageBoxResult.Cancel结果值。When a user clicks the Close button or presses the ESC key, a message box returns a message box result value of MessageBoxResult.Cancel. 但是, 如果消息框只显示 "确定" 按钮, 则单击 "关闭" 按钮或按ESC键将导致出现一个消息框, 返回一个MessageBoxResult.OK消息框结果值。However, if a message box displays only an OK button, clicking the Close button or pressing the ESC key causes a message box to return a message box result value of MessageBoxResult.OK.

适用于

另请参阅