ExceptionMessageBoxButtons 枚举
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定在异常消息框中显示的按钮。
public enum class ExceptionMessageBoxButtons
public enum ExceptionMessageBoxButtons
type ExceptionMessageBoxButtons =
Public Enum ExceptionMessageBoxButtons
- 继承
-
ExceptionMessageBoxButtons
字段
| 名称 | 值 | 说明 |
|---|---|---|
| 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 以确定用户点击了哪个按钮。