MessageBoxIcon 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指定要顯示之資訊的常數。
public enum class MessageBoxIcon
public enum MessageBoxIcon
type MessageBoxIcon =
Public Enum MessageBoxIcon
- 繼承
欄位
| 名稱 | 值 | Description |
|---|---|---|
| None | 0 | 訊息框中沒有任何符號。 |
| Error | 16 | 訊息框內有一個由白色 X 置於圓形中、紅色背景的符號。 |
| Hand | 16 | 訊息框內有一個符號,由一個白色 X 置於一個紅色背景的圓圈中組成。 |
| Stop | 16 | 訊息框內有一個由白色 X 置於圓形中、紅色背景的符號。 |
| Question | 32 | 訊息框內有一個圓形問號符號。 問號訊息圖示不再被推薦,因為它無法明確代表特定類型的訊息,且訊息的表述可能適用於任何訊息類型。 此外,使用者可能會將問號符號與說明資訊符號混淆。 因此,請勿在訊息框中使用這個問號符號。 系統仍僅支援其包含此功能,以確保向下相容。 |
| Exclamation | 48 | 訊息框內有一個由黃色背景三角形中的驚嘆號組成的符號。 |
| Warning | 48 | 訊息框內有一個由黃色背景三角形中的驚嘆號組成的符號。 |
| Asterisk | 64 | 訊息框內有一個符號,由一個小寫字母 i 組成,圓圈內。 |
| Information | 64 | 訊息框內有一個符號,由一個小寫字母 i 組成,圓圈內。 |
範例
以下程式碼範例展示了如何使用 來MessageBox通知使用者 中缺少的 。TextBox 此範例要求方法必須從帶有 a Button 和 a TextBox 的現有形式中呼叫。
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 。 這個枚舉中每個成員的描述都包含該符號的典型表示。 實際顯示的圖形是作業系統常數的函數。 在目前的實作中,有四個獨特的符號,並被賦予多個值。
下表顯示不同的訊息框圖示。
| Icon | Name |
|---|---|
, |
手 |
|
Question |
|
驚嘆 |
藍色 藍色 |
Asterisk |
, |
停止 |
, |
錯誤 |
|
警告 |
藍色 藍色 |
資訊 |
,
藍色 藍色
,
,
藍色 藍色