ExceptionMessageBox 類別

定義

顯示可自訂文字、按鈕與符號的訊息框,以提升Microsoft Windows .NET Framework應用程式的客戶體驗。

public ref class ExceptionMessageBox
[System.Runtime.InteropServices.ComVisible(false)]
public class ExceptionMessageBox
[<System.Runtime.InteropServices.ComVisible(false)>]
type ExceptionMessageBox = class
Public Class ExceptionMessageBox
繼承
ExceptionMessageBox
屬性

範例

這個例子顯示訊息框並有一個 確定 按鈕。

try
{
    // Do something that may generate an exception.
    throw new ApplicationException("An error has occured");
}
catch (ApplicationException ex)
{
    // Define a new top-level error message.
    string str = "The action failed.";

    // Add the new top-level message to the handled exception.
    ApplicationException exTop = new ApplicationException(str, ex);
    exTop.Source = this.Text;

    // Show an exception message box with an OK button (the default).
    ExceptionMessageBox box = new ExceptionMessageBox(exTop);
    box.Show(this);
}
Try
    ' Do something that may generate an exception.
    Throw New ApplicationException("An error has occured")
Catch ex As ApplicationException
    ' Define a new top-level error message.
    Dim str As String = "The action failed."

    ' Add the new top-level message to the handled exception.
    Dim exTop As ApplicationException = New ApplicationException(str, ex)
    exTop.Source = Me.Text

    ' Show an exception message box with an OK button (the default).
    Dim box As ExceptionMessageBox = New ExceptionMessageBox(exTop)
    box.Show(Me)
End Try

本範例使用例外訊息框來顯示有助於故障排除或除錯的額外資訊。

try
{
    // Do something that you don't expect to generate an exception.
    throw new ApplicationException("Failed to connect to the server.");
}
catch (ApplicationException ex)
{
    string str = "An unexpected error occurred. Please call Helpdesk.";
    ApplicationException exTop = new ApplicationException(str, ex);
    exTop.Source = this.Text;

    // Information in the Data property of an exception that has a name
    // beginning with "HelpLink.Advanced" is shown when the user
    // clicks the Advanced Information button of the exception message
    // box dialog box.
    exTop.Data.Add("AdvancedInformation.FileName", "application.dll");
    exTop.Data.Add("AdvancedInformation.FilePosition", "line 355");
    exTop.Data.Add("AdvancedInformation.UserContext", "single user mode");

    // Show the exception message box with additional information that 
    // is helpful when a user calls technical support.
    ExceptionMessageBox box = new ExceptionMessageBox(exTop);

    box.Show(this);
}
Try
    ' Do something that you don't expect to generate an exception.
    Throw New ApplicationException("Failed to connect to the server.")
Catch ex As ApplicationException
    Dim str As String = "An unexpected error occurred. Please call Helpdesk."
    Dim exTop As ApplicationException = New ApplicationException(str, ex)
    exTop.Source = Me.Text

    ' Information in the Data property of an exception that has a name
    ' beginning with "HelpLink.Advanced" is shown when the user
    ' clicks the Advanced Information button of the exception message
    ' box dialog box.
    exTop.Data.Add("AdvancedInformation.FileName", "application.dll")
    exTop.Data.Add("AdvancedInformation.FilePosition", "line 355")
    exTop.Data.Add("AdvancedInformation.UserContext", "single user mode")

    ' Show the exception message box with additional information that 
    ' is helpful when a user calls technical support.
    Dim box As ExceptionMessageBox = New ExceptionMessageBox(exTop)

    box.Show(Me)

End Try

建構函式

名稱 Description
ExceptionMessageBox()

建立一個帶有預設屬性的實 ExceptionMessageBox 例。

ExceptionMessageBox(Exception, ExceptionMessageBoxButtons, ExceptionMessageBoxSymbol, ExceptionMessageBoxDefaultButton, ExceptionMessageBoxOptions)

利用指定的Exception資訊,並指定按鈕、符號、預設按鈕及其他屬性,在例外訊息框中顯示,建立一個ExceptionMessageBox實例。

ExceptionMessageBox(Exception, ExceptionMessageBoxButtons, ExceptionMessageBoxSymbol, ExceptionMessageBoxDefaultButton)

利用指定的Exception資訊,並指定按鈕、符號及預設按鈕,在例外訊息框中顯示,建立一個ExceptionMessageBox實例。 .

ExceptionMessageBox(Exception, ExceptionMessageBoxButtons, ExceptionMessageBoxSymbol)

利用指定的Exception資訊,並指定訊息框中顯示的按鈕與符號,建立一個ExceptionMessageBox實例。

ExceptionMessageBox(Exception, ExceptionMessageBoxButtons)

利用指定的Exception資訊並指定訊息框中顯示的按鈕,建立一個ExceptionMessageBox實例。

ExceptionMessageBox(Exception)

利用指定Exception資訊建立 的ExceptionMessageBox實例。

ExceptionMessageBox(String, String, ExceptionMessageBoxButtons, ExceptionMessageBoxSymbol, ExceptionMessageBoxDefaultButton, ExceptionMessageBoxOptions)

建立一個包含頂層錯誤訊息文字及對話框說明的實例 ExceptionMessageBox 。 此方法同時指定在例外訊息框中顯示的按鈕、符號、預設按鈕及對話框選項。

ExceptionMessageBox(String, String, ExceptionMessageBoxButtons, ExceptionMessageBoxSymbol, ExceptionMessageBoxDefaultButton)

建立一個包含頂層錯誤訊息文字及對話框說明的實例 ExceptionMessageBox 。 此方法也指定在例外訊息框中顯示的按鈕、符號和預設按鈕。

ExceptionMessageBox(String, String, ExceptionMessageBoxButtons, ExceptionMessageBoxSymbol)

建立一個包含頂層錯誤訊息文字及例外訊息框對話框說明的實例 ExceptionMessageBox 。 此方法同時指定在例外訊息框中顯示的按鈕與符號。

ExceptionMessageBox(String, String, ExceptionMessageBoxButtons)

建立一個包含頂層錯誤訊息文字及例外訊息框對話框說明的實例 ExceptionMessageBox 。 此方法也指定要在例外訊息框中顯示的按鈕。

ExceptionMessageBox(String, String)

建立一個包含頂層錯誤訊息文字及例外訊息框對話框說明的實例 ExceptionMessageBox

ExceptionMessageBox(String)

建立一個包含頂層錯誤訊息文字的 ExceptionMessageBox 實例。

屬性

名稱 Description
AbortButtonText

會看到中 按鈕的預設文字。

Beep

指定在顯示訊息時是否播放可聽見的聲音。

Buttons

取得或設定按鈕顯示在訊息框中。

CancelButtonText

會看到 取消 按鈕的預設文字。

Caption

取得或設定例外訊息框的對話框標題。

CheckBoxRegistryKey

設定一個已開啟 RegistryKey 的,控制當 ShowCheckBoxtrue時,例外訊息框上顯示的勾選框。

CheckBoxRegistryMeansDoNotShowDialog

判斷登錄檔值內容是否由指定 CheckBoxRegistryKey ,並 CheckBoxRegistryValue 表示先前使用者決定不查看此訊息。

CheckBoxRegistryValue

取得或設定登錄檔值名稱,當 為 true時,控制例外訊息框ShowCheckBox上的勾選框。

CheckBoxText

ShowCheckBoxtrue時,取得或設定文字顯示在例外訊息框的勾選框中。

CustomDialogResult

會點擊自訂文字對話框按鈕。

CustomSymbol

取得或設定自訂位圖,作為例外訊息框上的符號。

Data

取得 IDictionary 儲存幫助連結及與頂層訊息相關的進階資訊的介面。

DefaultButton

取得或設定訊息框上的預設按鈕。

DefaultDialogResult

當使用者先前表示不再顯示該訊息時,會接收或設定方法回傳 Show(IWin32Window) 的值。

FailButtonText

會看到 失敗按鈕的 預設文字。

Font

取得或設定訊息框中使用的字型。

HelpLink

取得或設定與頂層訊息相關的說明檔案或說明網頁的連結。

IgnoreButtonText

會看到 忽略 按鈕的預設文字。

InnerException

取得或設定 Exception 與較低層訊息相關的實例。

IsCheckBoxChecked

指定當 ShowCheckBox 為 時 true是否選擇勾選 。

Message

取得或設定 Exception 包含訊息的 顯示。

MessageLevelDefault

接收或設定訊息框中顯示的訊息等級數量。

NoButtonText

會看到 「否」 按鈕的預設文字

OKButtonText

取得 確定 按鈕的預設文字

Options

取得或設定訊息框的各種顯示選項

RetryButtonText

會看到重 按鈕的預設文字。

ShowCheckBox

指定是否要在例外訊息框中顯示勾選框。

ShowToolBar

指定是否要在例外訊息框上顯示指令按鈕工具列。

Symbol

取得或設定該符號顯示在例外訊息框中。

Text

取得或設定頂層訊息的文字顯示於例外訊息框中

UseOwnerFont

指定是否要取得擁有者視窗的字型,並將其用作例外訊息框的字型。

YesButtonText

會看到「 是」 按鈕的預設文字

方法

名稱 Description
GetMessageText(Exception)

當例外顯示在例外訊息框中時,回傳使用者可複製到剪貼簿的字串。

SetButtonText(String, String, String, String, String)

當例外訊息框中僅顯示五個按鈕時,設定自訂文字按鈕的文字。

SetButtonText(String, String, String, String)

當例外訊息框中只顯示四個按鈕時,設定自訂文字按鈕的文字。

SetButtonText(String, String, String)

當例外訊息框中只顯示三個按鈕時,設定自訂文字按鈕的文字。

SetButtonText(String, String)

當例外訊息框中只顯示兩個按鈕時,設定自訂文字按鈕的文字。

SetButtonText(String)

當例外訊息框中只顯示一個按鈕時,設定自訂文字按鈕的文字。

Show(IntPtr, String, String, String, String, String, String, String)

顯示例外訊息框。 僅供參考之用。 不支援。 我們無法保證未來的相容性。

Show(IWin32Window)

它會以一個模式對話框的形式顯示,位於父視窗中心。

事件

名稱 Description
OnCopyToClipboard

當例外訊息文字從訊息框複製到剪貼簿時會發生。

適用於