Export (0) Print
Expand All

MessageBox.Show Method (String, String, MessageBoxButton, MessageBoxImage)

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

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

public static MessageBoxResult Show (
	string messageBoxText,
	string caption,
	MessageBoxButton button,
	MessageBoxImage icon
)
public static MessageBoxResult Show (
	String messageBoxText, 
	String caption, 
	MessageBoxButton button, 
	MessageBoxImage icon
)
public static function Show (
	messageBoxText : String, 
	caption : String, 
	button : MessageBoxButton, 
	icon : MessageBoxImage
) : MessageBoxResult
You cannot use methods in XAML.

Parameters

messageBoxText

A String that specifies the text to display.

caption

A String that specifies the title bar caption to display.

button

A MessageBoxButton value that specifies which button or buttons to display.

icon

A MessageBoxImage value that specifies the icon to display.

Return Value

A MessageBoxResult value that specifies which message box button is clicked by the user.

The following example shows how to use this overload of the Show method.

void showMessageBoxButton_Click(object sender, RoutedEventArgs e) {
  // Configure message box
  string message = "Hello, MessageBox!";
  string caption = "Caption text";
  MessageBoxButton buttons = MessageBoxButton.OKCancel;
  MessageBoxImage icon = MessageBoxImage.Information;
  // Show message box
  MessageBoxResult result = MessageBox.Show(message, caption, buttons, icon);
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft