MessageBox Class
TOC
Collapse the table of content
Expand the table of content

MessageBox Class

 

Displays a message box.

Namespace:   System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)

System.Object
  System.Windows.MessageBox

public sealed class MessageBox

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticShow(String)

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

System_CAPS_pubmethodSystem_CAPS_staticShow(String, String)

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

System_CAPS_pubmethodSystem_CAPS_staticShow(String, String, MessageBoxButton)

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

System_CAPS_pubmethodSystem_CAPS_staticShow(String, String, MessageBoxButton, MessageBoxImage)

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

System_CAPS_pubmethodSystem_CAPS_staticShow(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.

System_CAPS_pubmethodSystem_CAPS_staticShow(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.

System_CAPS_pubmethodSystem_CAPS_staticShow(Window, String)

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

System_CAPS_pubmethodSystem_CAPS_staticShow(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.

System_CAPS_pubmethodSystem_CAPS_staticShow(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.

System_CAPS_pubmethodSystem_CAPS_staticShow(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.

System_CAPS_pubmethodSystem_CAPS_staticShow(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.

System_CAPS_pubmethodSystem_CAPS_staticShow(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.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

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.

.NET Framework
Available since 3.0
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft