MessageBoxIcon 列挙型

定義

表示する情報を定義する定数を指定します。

public enum class MessageBoxIcon
public enum MessageBoxIcon
type MessageBoxIcon = 
Public Enum MessageBoxIcon
継承
MessageBoxIcon

フィールド

名前 説明
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に不足しているエントリをユーザーに通知する方法を示しています。 この例では、 ButtonTextBox を含む既存のフォームからメソッドを呼び出す必要があります。

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 クラスによって使用されます。 この列挙体の各メンバーの説明には、シンボルの一般的な表現が含まれています。 表示される実際のグラフィックは、オペレーティング システム定数の関数です。 現在の実装では、複数の値が割り当てられた 4 つの一意のシンボルがあります。

次の表に、さまざまなメッセージ ボックス アイコンを示します。

Icon 名前
赤い円の白い X 赤
青い円の白い疑問符 青 質問
黄色の三角形の黒い感嘆符 黄色 感嘆
青い円の白い小文字の i 青 Asterisk
赤い円の白い X 赤 止める
赤い円の白い X 赤 エラー
黄色の三角形の黒い感嘆符 黄色 Warning
青い円の白い小文字の i 青 情報

適用対象