共用方式為


MessageBox.Show 方法

定義

顯示訊息方塊。

多載

Show(String)

顯示訊息方塊,該訊息方塊含有訊息並傳回結果。

Show(String, String)

顯示訊息方塊,該訊息方塊含有訊息和標題列標題並傳回結果。

Show(Window, String)

在指定的視窗前顯示訊息方塊。 訊息方塊會顯示訊息並傳回結果。

Show(String, String, MessageBoxButton)

顯示訊息方塊,該訊息方塊含有訊息、標題列標題和按鈕並傳回結果。

Show(Window, String, String)

在指定的視窗前顯示訊息方塊。 訊息方塊會顯示訊息和標題列標題,並傳回結果。

Show(String, String, MessageBoxButton, MessageBoxImage)

顯示訊息方塊,該訊息方塊含有訊息、標題列標題、按鈕和圖示並傳回結果。

Show(Window, String, String, MessageBoxButton)

在指定的視窗前顯示訊息方塊。 訊息方塊會顯示訊息、標題列標題和按鈕,還會傳回結果。

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

顯示訊息方塊,該訊息方塊含有訊息、標題列標題、按鈕和圖示、接受預設訊息方塊結果並傳回結果。

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

在指定的視窗前顯示訊息方塊。 訊息方塊會顯示訊息、標題列標題、按鈕和圖示,還會傳回結果。

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

顯示訊息方塊,該訊息方塊含有訊息、標題列標題、按鈕和圖示、接受預設訊息方塊結果、遵循指定之選項並傳回結果。

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

在指定的視窗前顯示訊息方塊。 訊息方塊會顯示訊息、標題列標題、按鈕和圖示、接受預設訊息方塊結果並傳回結果。

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

在指定的視窗前顯示訊息方塊。 訊息方塊會顯示訊息、標題列標題、按鈕和圖示、且接受預設訊息方塊結果、遵循指定之選項並傳回結果。

備註

使用 方法的多 Show 載,可讓您指定擁有者視窗。 否則,訊息方塊是由目前使用中的視窗所擁有。

Show(String)

顯示訊息方塊,該訊息方塊含有訊息並傳回結果。

public:
 static System::Windows::MessageBoxResult Show(System::String ^ messageBoxText);
[System.Security.SecurityCritical]
public static System.Windows.MessageBoxResult Show (string messageBoxText);
public static System.Windows.MessageBoxResult Show (string messageBoxText);
[<System.Security.SecurityCritical>]
static member Show : string -> System.Windows.MessageBoxResult
static member Show : string -> System.Windows.MessageBoxResult
Public Shared Function Show (messageBoxText As String) As MessageBoxResult

參數

messageBoxText
String

String,指定要顯示的文字。

傳回

MessageBoxResult

MessageBoxResult 值,指定使用者所按的訊息方塊按鈕。

屬性

範例

下列範例示範如何使用 方法的 Show 這個多載。

private void ShowMessageBoxButton_Click(object sender, RoutedEventArgs e)
{
    // Configure message box
    string message = "Hello, MessageBox!";
    // Show message box
    MessageBoxResult result = MessageBox.Show(message);
}
Private Sub showMessageBoxButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    ' Configure message box
    Dim message As String = "Hello, MessageBox!"
    ' Show message box
    Dim result As MessageBoxResult = MessageBox.Show(message)
End Sub

適用於

Show(String, String)

顯示訊息方塊,該訊息方塊含有訊息和標題列標題並傳回結果。

public:
 static System::Windows::MessageBoxResult Show(System::String ^ messageBoxText, System::String ^ caption);
[System.Security.SecurityCritical]
public static System.Windows.MessageBoxResult Show (string messageBoxText, string caption);
public static System.Windows.MessageBoxResult Show (string messageBoxText, string caption);
[<System.Security.SecurityCritical>]
static member Show : string * string -> System.Windows.MessageBoxResult
static member Show : string * string -> System.Windows.MessageBoxResult
Public Shared Function Show (messageBoxText As String, caption As String) As MessageBoxResult

參數

messageBoxText
String

String,指定要顯示的文字。

caption
String

String,指定要顯示的標題列標題。

傳回

MessageBoxResult

MessageBoxResult 值,指定使用者所按的訊息方塊按鈕。

屬性

範例

下列範例示範如何使用 方法的 Show 這個多載。

private void ShowMessageBoxButton_Click(object sender, RoutedEventArgs e)
{
    // Configure message box
    string message = "Message text";
    string caption = "Caption text";
    // Show message box
    MessageBoxResult result = MessageBox.Show(message, caption);
}
Private Sub showMessageBoxButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    ' Configure message box
    Dim message As String = "Message text"
    Dim caption As String = "Caption text"
    ' Show message box
    Dim result As MessageBoxResult = MessageBox.Show(message, caption)
End Sub

適用於

Show(Window, String)

在指定的視窗前顯示訊息方塊。 訊息方塊會顯示訊息並傳回結果。

public:
 static System::Windows::MessageBoxResult Show(System::Windows::Window ^ owner, System::String ^ messageBoxText);
[System.Security.SecurityCritical]
public static System.Windows.MessageBoxResult Show (System.Windows.Window owner, string messageBoxText);
public static System.Windows.MessageBoxResult Show (System.Windows.Window owner, string messageBoxText);
[<System.Security.SecurityCritical>]
static member Show : System.Windows.Window * string -> System.Windows.MessageBoxResult
static member Show : System.Windows.Window * string -> System.Windows.MessageBoxResult
Public Shared Function Show (owner As Window, messageBoxText As String) As MessageBoxResult

參數

owner
Window

Window,表示訊息方塊的主控視窗。

messageBoxText
String

String,指定要顯示的文字。

傳回

MessageBoxResult

MessageBoxResult 值,指定使用者所按的訊息方塊按鈕。

屬性

備註

根據預設,訊息方塊會出現在目前作用中的視窗前面。

另請參閱

適用於

Show(String, String, MessageBoxButton)

顯示訊息方塊,該訊息方塊含有訊息、標題列標題和按鈕並傳回結果。

public:
 static System::Windows::MessageBoxResult Show(System::String ^ messageBoxText, System::String ^ caption, System::Windows::MessageBoxButton button);
[System.Security.SecurityCritical]
public static System.Windows.MessageBoxResult Show (string messageBoxText, string caption, System.Windows.MessageBoxButton button);
public static System.Windows.MessageBoxResult Show (string messageBoxText, string caption, System.Windows.MessageBoxButton button);
[<System.Security.SecurityCritical>]
static member Show : string * string * System.Windows.MessageBoxButton -> System.Windows.MessageBoxResult
static member Show : string * string * System.Windows.MessageBoxButton -> System.Windows.MessageBoxResult
Public Shared Function Show (messageBoxText As String, caption As String, button As MessageBoxButton) As MessageBoxResult

參數

messageBoxText
String

String,指定要顯示的文字。

caption
String

String,指定要顯示的標題列標題。

button
MessageBoxButton

MessageBoxButton 值,指定要顯示的一個或多個按鈕。

傳回

MessageBoxResult

MessageBoxResult 值,指定使用者所按的訊息方塊按鈕。

屬性

範例

下列範例示範如何使用 方法的 Show 這個多載。

private void ShowMessageBoxButton_Click(object sender, RoutedEventArgs e)
{
    // Configure message box
    string message = "Hello, MessageBox!";
    string caption = "Caption text";
    MessageBoxButton buttons = MessageBoxButton.OKCancel;
    // Show message box
    MessageBoxResult result = MessageBox.Show(message, caption, buttons);
}
Private Sub showMessageBoxButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    ' Configure message box
    Dim message As String = "Hello, MessageBox!"
    Dim caption As String = "Caption text"
    Dim buttons As MessageBoxButton = MessageBoxButton.OKCancel
    ' Show message box
    Dim result As MessageBoxResult = MessageBox.Show(message, caption, buttons)
End Sub

適用於

Show(Window, String, String)

在指定的視窗前顯示訊息方塊。 訊息方塊會顯示訊息和標題列標題,並傳回結果。

public:
 static System::Windows::MessageBoxResult Show(System::Windows::Window ^ owner, System::String ^ messageBoxText, System::String ^ caption);
[System.Security.SecurityCritical]
public static System.Windows.MessageBoxResult Show (System.Windows.Window owner, string messageBoxText, string caption);
public static System.Windows.MessageBoxResult Show (System.Windows.Window owner, string messageBoxText, string caption);
[<System.Security.SecurityCritical>]
static member Show : System.Windows.Window * string * string -> System.Windows.MessageBoxResult
static member Show : System.Windows.Window * string * string -> System.Windows.MessageBoxResult
Public Shared Function Show (owner As Window, messageBoxText As String, caption As String) As MessageBoxResult

參數

owner
Window

Window,表示訊息方塊的主控視窗。

messageBoxText
String

String,指定要顯示的文字。

caption
String

String,指定要顯示的標題列標題。

傳回

MessageBoxResult

MessageBoxResult 值,指定使用者所按的訊息方塊按鈕。

屬性

備註

根據預設,訊息方塊會出現在目前作用中的視窗前面。

另請參閱

適用於

Show(String, String, MessageBoxButton, MessageBoxImage)

顯示訊息方塊,該訊息方塊含有訊息、標題列標題、按鈕和圖示並傳回結果。

public:
 static System::Windows::MessageBoxResult Show(System::String ^ messageBoxText, System::String ^ caption, System::Windows::MessageBoxButton button, System::Windows::MessageBoxImage icon);
[System.Security.SecurityCritical]
public static System.Windows.MessageBoxResult Show (string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon);
public static System.Windows.MessageBoxResult Show (string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon);
[<System.Security.SecurityCritical>]
static member Show : string * string * System.Windows.MessageBoxButton * System.Windows.MessageBoxImage -> System.Windows.MessageBoxResult
static member Show : string * string * System.Windows.MessageBoxButton * System.Windows.MessageBoxImage -> System.Windows.MessageBoxResult
Public Shared Function Show (messageBoxText As String, caption As String, button As MessageBoxButton, icon As MessageBoxImage) As MessageBoxResult

參數

messageBoxText
String

String,指定要顯示的文字。

caption
String

String,指定要顯示的標題列標題。

button
MessageBoxButton

MessageBoxButton 值,指定要顯示的一個或多個按鈕。

icon
MessageBoxImage

MessageBoxImage 值,指定要顯示的圖示。

傳回

MessageBoxResult

MessageBoxResult 值,指定使用者所按的訊息方塊按鈕。

屬性

範例

下列範例示範如何使用 方法的 Show 這個多載。

private 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);
}
Private Sub showMessageBoxButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    ' Configure message box
    Dim message As String = "Hello, MessageBox!"
    Dim caption As String = "Caption text"
    Dim buttons As MessageBoxButton = MessageBoxButton.OKCancel
    Dim icon As MessageBoxImage = MessageBoxImage.Information
    ' Show message box
    Dim result As MessageBoxResult = MessageBox.Show(message, caption, buttons, icon)
End Sub

適用於

Show(Window, String, String, MessageBoxButton)

在指定的視窗前顯示訊息方塊。 訊息方塊會顯示訊息、標題列標題和按鈕,還會傳回結果。

public:
 static System::Windows::MessageBoxResult Show(System::Windows::Window ^ owner, System::String ^ messageBoxText, System::String ^ caption, System::Windows::MessageBoxButton button);
[System.Security.SecurityCritical]
public static System.Windows.MessageBoxResult Show (System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button);
public static System.Windows.MessageBoxResult Show (System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button);
[<System.Security.SecurityCritical>]
static member Show : System.Windows.Window * string * string * System.Windows.MessageBoxButton -> System.Windows.MessageBoxResult
static member Show : System.Windows.Window * string * string * System.Windows.MessageBoxButton -> System.Windows.MessageBoxResult
Public Shared Function Show (owner As Window, messageBoxText As String, caption As String, button As MessageBoxButton) As MessageBoxResult

參數

owner
Window

Window,表示訊息方塊的主控視窗。

messageBoxText
String

String,指定要顯示的文字。

caption
String

String,指定要顯示的標題列標題。

button
MessageBoxButton

MessageBoxButton 值,指定要顯示的一個或多個按鈕。

傳回

MessageBoxResult

MessageBoxResult 值,指定使用者所按的訊息方塊按鈕。

屬性

備註

根據預設,訊息方塊會出現在目前作用中的視窗前面。

另請參閱

適用於

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

顯示訊息方塊,該訊息方塊含有訊息、標題列標題、按鈕和圖示、接受預設訊息方塊結果並傳回結果。

public:
 static System::Windows::MessageBoxResult Show(System::String ^ messageBoxText, System::String ^ caption, System::Windows::MessageBoxButton button, System::Windows::MessageBoxImage icon, System::Windows::MessageBoxResult defaultResult);
[System.Security.SecurityCritical]
public static System.Windows.MessageBoxResult Show (string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult defaultResult);
public static System.Windows.MessageBoxResult Show (string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult defaultResult);
[<System.Security.SecurityCritical>]
static member Show : string * string * System.Windows.MessageBoxButton * System.Windows.MessageBoxImage * System.Windows.MessageBoxResult -> System.Windows.MessageBoxResult
static member Show : string * string * System.Windows.MessageBoxButton * System.Windows.MessageBoxImage * System.Windows.MessageBoxResult -> System.Windows.MessageBoxResult
Public Shared Function Show (messageBoxText As String, caption As String, button As MessageBoxButton, icon As MessageBoxImage, defaultResult As MessageBoxResult) As MessageBoxResult

參數

messageBoxText
String

String,指定要顯示的文字。

caption
String

String,指定要顯示的標題列標題。

button
MessageBoxButton

MessageBoxButton 值,指定要顯示的一個或多個按鈕。

icon
MessageBoxImage

MessageBoxImage 值,指定要顯示的圖示。

defaultResult
MessageBoxResult

MessageBoxResult 值,指定訊息方塊的預設結果。

傳回

MessageBoxResult

MessageBoxResult 值,指定使用者所按的訊息方塊按鈕。

屬性

範例

下列範例示範如何使用 方法的 Show 這個多載。

private 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;
    MessageBoxResult defaultResult = MessageBoxResult.OK;
    // Show message box
    MessageBoxResult result = MessageBox.Show(message, caption, buttons, icon, defaultResult);
}
Private Sub showMessageBoxButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    ' Configure message box
    Dim message As String = "Hello, MessageBox!"
    Dim caption As String = "Caption text"
    Dim buttons As MessageBoxButton = MessageBoxButton.OKCancel
    Dim icon As MessageBoxImage = MessageBoxImage.Information
    Dim defaultResult As MessageBoxResult = MessageBoxResult.OK
    ' Show message box
    Dim result As MessageBoxResult = MessageBox.Show(message, caption, buttons, icon, defaultResult)
End Sub

適用於

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

在指定的視窗前顯示訊息方塊。 訊息方塊會顯示訊息、標題列標題、按鈕和圖示,還會傳回結果。

public:
 static System::Windows::MessageBoxResult Show(System::Windows::Window ^ owner, System::String ^ messageBoxText, System::String ^ caption, System::Windows::MessageBoxButton button, System::Windows::MessageBoxImage icon);
[System.Security.SecurityCritical]
public static System.Windows.MessageBoxResult Show (System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon);
public static System.Windows.MessageBoxResult Show (System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon);
[<System.Security.SecurityCritical>]
static member Show : System.Windows.Window * string * string * System.Windows.MessageBoxButton * System.Windows.MessageBoxImage -> System.Windows.MessageBoxResult
static member Show : System.Windows.Window * string * string * System.Windows.MessageBoxButton * System.Windows.MessageBoxImage -> System.Windows.MessageBoxResult
Public Shared Function Show (owner As Window, messageBoxText As String, caption As String, button As MessageBoxButton, icon As MessageBoxImage) As MessageBoxResult

參數

owner
Window

Window,表示訊息方塊的主控視窗。

messageBoxText
String

String,指定要顯示的文字。

caption
String

String,指定要顯示的標題列標題。

button
MessageBoxButton

MessageBoxButton 值,指定要顯示的一個或多個按鈕。

icon
MessageBoxImage

MessageBoxImage 值,指定要顯示的圖示。

傳回

MessageBoxResult

MessageBoxResult 值,指定使用者所按的訊息方塊按鈕。

屬性

備註

根據預設,訊息方塊會出現在目前作用中的視窗前面。

另請參閱

適用於

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

顯示訊息方塊,該訊息方塊含有訊息、標題列標題、按鈕和圖示、接受預設訊息方塊結果、遵循指定之選項並傳回結果。

public:
 static System::Windows::MessageBoxResult Show(System::String ^ messageBoxText, System::String ^ caption, System::Windows::MessageBoxButton button, System::Windows::MessageBoxImage icon, System::Windows::MessageBoxResult defaultResult, System::Windows::MessageBoxOptions options);
[System.Security.SecurityCritical]
public static System.Windows.MessageBoxResult Show (string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult defaultResult, System.Windows.MessageBoxOptions options);
public static System.Windows.MessageBoxResult Show (string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult defaultResult, System.Windows.MessageBoxOptions options);
[<System.Security.SecurityCritical>]
static member Show : string * string * System.Windows.MessageBoxButton * System.Windows.MessageBoxImage * System.Windows.MessageBoxResult * System.Windows.MessageBoxOptions -> System.Windows.MessageBoxResult
static member Show : string * string * System.Windows.MessageBoxButton * System.Windows.MessageBoxImage * System.Windows.MessageBoxResult * System.Windows.MessageBoxOptions -> System.Windows.MessageBoxResult
Public Shared Function Show (messageBoxText As String, caption As String, button As MessageBoxButton, icon As MessageBoxImage, defaultResult As MessageBoxResult, options As MessageBoxOptions) As MessageBoxResult

參數

messageBoxText
String

String,指定要顯示的文字。

caption
String

String,指定要顯示的標題列標題。

button
MessageBoxButton

MessageBoxButton 值,指定要顯示的一個或多個按鈕。

icon
MessageBoxImage

MessageBoxImage 值,指定要顯示的圖示。

defaultResult
MessageBoxResult

MessageBoxResult 值,指定訊息方塊的預設結果。

options
MessageBoxOptions

MessageBoxOptions 值物件,指定選項。

傳回

MessageBoxResult

MessageBoxResult 值,指定使用者所按的訊息方塊按鈕。

屬性

範例

下列範例示範如何使用 方法的 Show 這個多載。

private 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;
    MessageBoxResult defaultResult = MessageBoxResult.OK;
    MessageBoxOptions options = MessageBoxOptions.RtlReading;
    // Show message box
    MessageBoxResult result = MessageBox.Show(message, caption, buttons, icon, defaultResult, options);
}
Private Sub showMessageBoxButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    ' Configure message box
    Dim message As String = "Hello, MessageBox!"
    Dim caption As String = "Caption text"
    Dim buttons As MessageBoxButton = MessageBoxButton.OKCancel
    Dim icon As MessageBoxImage = MessageBoxImage.Information
    Dim defaultResult As MessageBoxResult = MessageBoxResult.OK
    Dim options As MessageBoxOptions = MessageBoxOptions.RtlReading
    ' Show message box
    Dim result As MessageBoxResult = MessageBox.Show(message, caption, buttons, icon, defaultResult, options)
End Sub

適用於

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

在指定的視窗前顯示訊息方塊。 訊息方塊會顯示訊息、標題列標題、按鈕和圖示、接受預設訊息方塊結果並傳回結果。

public:
 static System::Windows::MessageBoxResult Show(System::Windows::Window ^ owner, System::String ^ messageBoxText, System::String ^ caption, System::Windows::MessageBoxButton button, System::Windows::MessageBoxImage icon, System::Windows::MessageBoxResult defaultResult);
[System.Security.SecurityCritical]
public static System.Windows.MessageBoxResult Show (System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult defaultResult);
public static System.Windows.MessageBoxResult Show (System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult defaultResult);
[<System.Security.SecurityCritical>]
static member Show : System.Windows.Window * string * string * System.Windows.MessageBoxButton * System.Windows.MessageBoxImage * System.Windows.MessageBoxResult -> System.Windows.MessageBoxResult
static member Show : System.Windows.Window * string * string * System.Windows.MessageBoxButton * System.Windows.MessageBoxImage * System.Windows.MessageBoxResult -> System.Windows.MessageBoxResult
Public Shared Function Show (owner As Window, messageBoxText As String, caption As String, button As MessageBoxButton, icon As MessageBoxImage, defaultResult As MessageBoxResult) As MessageBoxResult

參數

owner
Window

Window,表示訊息方塊的主控視窗。

messageBoxText
String

String,指定要顯示的文字。

caption
String

String,指定要顯示的標題列標題。

button
MessageBoxButton

MessageBoxButton 值,指定要顯示的一個或多個按鈕。

icon
MessageBoxImage

MessageBoxImage 值,指定要顯示的圖示。

defaultResult
MessageBoxResult

MessageBoxResult 值,指定訊息方塊的預設結果。

傳回

MessageBoxResult

MessageBoxResult 值,指定使用者所按的訊息方塊按鈕。

屬性

備註

根據預設,訊息方塊會出現在目前作用中的視窗前面。

另請參閱

適用於

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

在指定的視窗前顯示訊息方塊。 訊息方塊會顯示訊息、標題列標題、按鈕和圖示、且接受預設訊息方塊結果、遵循指定之選項並傳回結果。

public:
 static System::Windows::MessageBoxResult Show(System::Windows::Window ^ owner, System::String ^ messageBoxText, System::String ^ caption, System::Windows::MessageBoxButton button, System::Windows::MessageBoxImage icon, System::Windows::MessageBoxResult defaultResult, System::Windows::MessageBoxOptions options);
[System.Security.SecurityCritical]
public static System.Windows.MessageBoxResult Show (System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult defaultResult, System.Windows.MessageBoxOptions options);
public static System.Windows.MessageBoxResult Show (System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult defaultResult, System.Windows.MessageBoxOptions options);
[<System.Security.SecurityCritical>]
static member Show : System.Windows.Window * string * string * System.Windows.MessageBoxButton * System.Windows.MessageBoxImage * System.Windows.MessageBoxResult * System.Windows.MessageBoxOptions -> System.Windows.MessageBoxResult
static member Show : System.Windows.Window * string * string * System.Windows.MessageBoxButton * System.Windows.MessageBoxImage * System.Windows.MessageBoxResult * System.Windows.MessageBoxOptions -> System.Windows.MessageBoxResult
Public Shared Function Show (owner As Window, messageBoxText As String, caption As String, button As MessageBoxButton, icon As MessageBoxImage, defaultResult As MessageBoxResult, options As MessageBoxOptions) As MessageBoxResult

參數

owner
Window

Window,表示訊息方塊的主控視窗。

messageBoxText
String

String,指定要顯示的文字。

caption
String

String,指定要顯示的標題列標題。

button
MessageBoxButton

MessageBoxButton 值,指定要顯示的一個或多個按鈕。

icon
MessageBoxImage

MessageBoxImage 值,指定要顯示的圖示。

defaultResult
MessageBoxResult

MessageBoxResult 值,指定訊息方塊的預設結果。

options
MessageBoxOptions

MessageBoxOptions 值物件,指定選項。

傳回

MessageBoxResult

MessageBoxResult 值,指定使用者所按的訊息方塊按鈕。

屬性

備註

根據預設,訊息方塊會出現在目前作用中的視窗前面。

另請參閱

適用於