ExceptionMessageBoxButtons 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指定在例外訊息框中顯示的按鈕。
public enum class ExceptionMessageBoxButtons
public enum ExceptionMessageBoxButtons
type ExceptionMessageBoxButtons =
Public Enum ExceptionMessageBoxButtons
- 繼承
-
ExceptionMessageBoxButtons
欄位
| 名稱 | 值 | Description |
|---|---|---|
| OK | 0 | 顯示 確定 按鈕。 |
| OKCancel | 1 | 顯示 確定 與 取消 按鈕。 |
| YesNoCancel | 2 | 顯示 是、 否和 取消 按鈕。 |
| YesNo | 3 | 顯示 是 與 否 按鈕。 |
| AbortRetryIgnore | 4 | 顯示 中止、 重試和 忽略 按鈕。 |
| RetryCancel | 5 | 顯示 重試 和 取消 按鈕。 |
| Custom | 6 | 顯示按鈕並附上自訂按鈕文字。 |
範例
// Define the message and caption to display.
string str = @"Are you sure you want to delete file 'c:\somefile.txt'?";
string caption = "Confirm File Deletion";
// Show the exception message box with Yes and No buttons.
ExceptionMessageBox box = new ExceptionMessageBox(str,
caption, ExceptionMessageBoxButtons.YesNo,
ExceptionMessageBoxSymbol.Question,
ExceptionMessageBoxDefaultButton.Button2);
if (DialogResult.Yes == box.Show(this))
{
// Delete the file.
}
' Define the message and caption to display.
Dim str As String = "Are you sure you want to delete file 'c:\somefile.txt'?"
Dim caption As String = "Confirm File Deletion"
' Show the exception message box with Yes and No buttons.
Dim box As ExceptionMessageBox = New ExceptionMessageBox(str, _
caption, ExceptionMessageBoxButtons.YesNo, _
ExceptionMessageBoxSymbol.Question, _
ExceptionMessageBoxDefaultButton.Button2)
If Windows.Forms.DialogResult.Yes = box.Show(Me) Then
' Delete the file.
End If
備註
當你使用 Custom時,必須先設定 SetButtonText 按鈕文字,才能顯示訊息框。 使用者關閉例外訊息框後,呼叫 CustomDialogResult 以確認使用者點擊了哪個按鈕。