MessageBoxIcon 枚举
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定要显示的信息的常量。
public enum class MessageBoxIcon
public enum MessageBoxIcon
type MessageBoxIcon =
Public Enum MessageBoxIcon
- 继承
字段
| 名称 | 值 | 说明 |
|---|---|---|
| None | 0 | 消息框不包含任何符号。 |
| Error | 16 | 消息框包含一个符号,该符号由带红色背景的圆圈中的白色 X 组成。 |
| Hand | 16 | 消息框包含一个符号,该符号由带红色背景的圆圈中的白色 X 组成。 |
| Stop | 16 | 消息框包含一个符号,该符号由带红色背景的圆圈中的白色 X 组成。 |
| Question | 32 | 消息框包含由圆圈中的问号组成的符号。 不再建议使用问号消息图标,因为它不明确表示特定类型的消息,并且因为作为问题的邮件短语可能适用于任何消息类型。 此外,用户可以将问号符号与帮助信息符号混淆。 因此,请勿在消息框中使用此问号符号。 系统继续支持其包含,仅用于向后兼容性。 |
| Exclamation | 48 | 消息框包含一个符号,该符号由带有黄色背景的三角形中的感叹号组成。 |
| Warning | 48 | 消息框包含一个符号,该符号由带有黄色背景的三角形中的感叹号组成。 |
| Asterisk | 64 | 消息框包含一个符号,该符号由圆圈中的小写字母 i 组成。 |
| Information | 64 | 消息框包含一个符号,该符号由圆圈中的小写字母 i 组成。 |
示例
下面的代码示例演示如何使用 a MessageBox 来通知用户缺少的 TextBox条目。 此示例要求从具有 a Button 和 TextBox on 的现有窗体调用该方法。
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
const string message =
"Are you sure that you would like to close the form?";
const string caption = "Form Closing";
var result = MessageBox.Show(message, caption,
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation);
// If the no button was pressed ...
if (result == DialogResult.No)
{
// cancel the closure of the form.
e.Cancel = true;
}
}
Private Sub Form1_FormClosing( _
ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.FormClosingEventArgs) _
Handles MyBase.FormClosing
Dim message As String = _
"Are you sure that you would like to close the form?"
Dim caption As String = "Form Closing"
Dim result = MessageBox.Show(message, caption, _
MessageBoxButtons.YesNo, _
MessageBoxIcon.Exclamation)
' If the no button was pressed ...
If (result = DialogResult.No) Then
' cancel the closure of the form.
e.Cancel = True
End If
End Sub
注解
此枚举由 MessageBox 类使用。 此枚举的每个成员的说明都包含符号的典型表示形式。 显示的实际图形是操作系统常量的功能。 在当前实现中,有四个唯一符号,其中分配了多个值。
下表显示了不同的消息框图标。
| 图标 | 名称 |
|---|---|
|
手 |
蓝色 |
Question |
|
惊叹号 |
|
星号 |
|
停下 |
|
Error |
|
Warning |
|
信息 |
蓝色