Uredi

Deli z drugimi prek


MessageBox Class

Definition

Displays a message box.

public ref class MessageBox sealed
public sealed class MessageBox
type MessageBox = class
Public NotInheritable Class MessageBox
Inheritance
MessageBox

Remarks

A message box is a prefabricated modal dialog box that displays a text message to a user. You show a message box by calling the static Show method of the MessageBox class. The text message that is displayed is the string argument that you pass to Show. Several overloads of the Show method also enables you to provide a title bar caption.

To enable a user to close a message box, Show displays a message box that has an OK button and a Close button in the title bar.

You can also use a message box to ask a user a question. The user answers by clicking one of several buttons that you specify to display by using the MessageBoxButton enumeration. You can pass this enumeration to several overloads of the Show method. The default value of the MessageBoxButton enumeration is OK.

You can determine which button a user clicks by examining the value that Show returns. The return value is a value of the MessageBoxResult enumeration, where each value equates to one of the buttons that a message box can display. The default value for message box is OK because OK is the default message box button. However, some overloads of the Show method enable you to provide a different MessageBoxResult default value.

Message boxes can communicate information and can ask questions that have varying degrees of importance. Message boxes use icons to indicate importance. For example, icons can indicate whether the message is informational, is a warning, or is important. The MessageBoxImage enumeration encapsulates the set of possible message box icons. By default, a message box does not display an icon. However, you can pass a MessageBoxImage value to one of several Show method overloads in order to specify that the message box includes an icon.

Message boxes sometimes provide special functionality, such as right-to-left reading. You can customize the behavior of a message box by using one or more MessageBoxOptions enumeration values that are accepted by some overloads of the Show method.

Message boxes always have an owner window. By default, the owner of a message box is the window that is currently active in an application at the time that a message box is opened. However, you can specify another owner for the Window by using one of several Show overloads. For more information about owner windows, see Window.Owner.

For more information, see MessageBox Sample.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Show(String, String, MessageBoxButton, MessageBoxImage, MessageBoxResult, MessageBoxOptions)

Displays a message box that has a message, title bar caption, button, and icon; and that accepts a default message box result, complies with the specified options, and returns a result.

Show(String, String, MessageBoxButton, MessageBoxImage, MessageBoxResult)

Displays a message box that has a message, title bar caption, button, and icon; and that accepts a default message box result and returns a result.

Show(String, String, MessageBoxButton, MessageBoxImage)

Displays a message box that has a message, title bar caption, button, and icon; and that returns a result.

Show(String, String, MessageBoxButton)

Displays a message box that has a message, title bar caption, and button; and that returns a result.

Show(String, String)

Displays a message box that has a message and title bar caption; and that returns a result.

Show(String)

Displays a message box that has a message and that returns a result.

Show(Window, String, String, MessageBoxButton, MessageBoxImage, MessageBoxResult, MessageBoxOptions)

Displays a message box in front of the specified window. The message box displays a message, title bar caption, button, and icon; and accepts a default message box result, complies with the specified options, and returns a result.

Show(Window, String, String, MessageBoxButton, MessageBoxImage, MessageBoxResult)

Displays a message box in front of the specified window. The message box displays a message, title bar caption, button, and icon; and accepts a default message box result and returns a result.

Show(Window, String, String, MessageBoxButton, MessageBoxImage)

Displays a message box in front of the specified window. The message box displays a message, title bar caption, button, and icon; and it also returns a result.

Show(Window, String, String, MessageBoxButton)

Displays a message box in front of the specified window. The message box displays a message, title bar caption, and button; and it also returns a result.

Show(Window, String, String)

Displays a message box in front of the specified window. The message box displays a message and title bar caption; and it returns a result.

Show(Window, String)

Displays a message box in front of the specified window. The message box displays a message and returns a result.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also