Show Method (String, String, MessageBoxButton)
Collapse the table of content
Expand the table of content

MessageBox.Show Method (String, String, MessageBoxButton)

Displays a message box that contains the specified text, title bar caption, and response buttons.

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

'Declaration
Public Shared Function Show ( _
	messageBoxText As String, _
	caption As String, _
	button As MessageBoxButton _
) As MessageBoxResult

Parameters

messageBoxText
Type: System.String
The message to display.
caption
Type: System.String
The title of the message box.
button
Type: System.Windows.MessageBoxButton
A value that indicates the button or buttons to display.

Return Value

Type: System.Windows.MessageBoxResult
A value that indicates the user's response to the message.

ExceptionCondition
ArgumentNullException

messageBoxText is Nothing.

-or-

caption is Nothing.

ArgumentException

button is not a valid MessageBoxButton value.

The message box is modal, which means that the user must click a button or press ESC to dismiss the message.

If the button parameter is OK, then the return value is OK in all cases.

If the button parameter is OKCancel, then the return value is OK only when the user has clicked the OK button. Otherwise, the return value is Cancel.

The following example code demonstrates how to use this method.


Dim result As MessageBoxResult = _
    MessageBox.Show("Would you like to see the simple version?", _
    "MessageBox Example", MessageBoxButton.OKCancel)

If (result = MessageBoxResult.OK) Then
    MessageBox.Show("No caption, one button.")
End If


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2016 Microsoft