Editar

Partilhar via


MessageBoxButton Enum

Definition

Specifies the buttons that are displayed on a message box. Used as an argument of the Show method.

public enum class MessageBoxButton
public enum MessageBoxButton
type MessageBoxButton = 
Public Enum MessageBoxButton
Inheritance
MessageBoxButton

Fields

Name Value Description
OK 0

The message box displays an OK button.

OKCancel 1

The message box displays OK and Cancel buttons.

YesNoCancel 3

The message box displays Yes, No, and Cancel buttons.

YesNo 4

The message box displays Yes and No buttons.

Examples

For more information, see the MessageBox Sample on GitHub.

Remarks

By default, the MessageBox.Show method displays a message box that has an OK button. 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.

The value of the button that a user clicks is returned by MessageBox.Show and is one of the values of the MessageBoxResult enumeration.

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. When a user clicks the Close button or presses the ESC key, a message box returns a message box result value of MessageBoxResult.Cancel. 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.

Applies to

See also