Export (0) Print
Expand All
Expand Minimize

MessageBoxIcon Enumeration

Specifies constants defining which information to display.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public enum MessageBoxIcon

Member nameDescription
Supported by the .NET Compact FrameworkNoneThe message box contain no symbols.
Supported by the .NET Compact FrameworkHandThe message box contains a symbol consisting of a white X in a circle with a red background.
Supported by the .NET Compact FrameworkQuestionThe message box contains a symbol consisting of a question mark in a circle. The question-mark message icon is no longer recommended because it does not clearly represent a specific type of message and because the phrasing of a message as a question could apply to any message type. In addition, users can confuse the message symbol question mark with Help information. Therefore, do not use this question mark message symbol in your message boxes. The system continues to support its inclusion only for backward compatibility.
Supported by the .NET Compact FrameworkExclamationThe message box contains a symbol consisting of an exclamation point in a triangle with a yellow background.
Supported by the .NET Compact FrameworkAsteriskThe message box contains a symbol consisting of a lowercase letter i in a circle.
StopThe message box contains a symbol consisting of white X in a circle with a red background.
ErrorThe message box contains a symbol consisting of white X in a circle with a red background.
WarningThe message box contains a symbol consisting of an exclamation point in a triangle with a yellow background.
InformationThe message box contains a symbol consisting of a lowercase letter i in a circle.

This enumeration is used by the MessageBox class. The description of each member of this enumeration contains a typical representation of the symbol. The actual graphic displayed is a function of the operating system constants. In current implementations there are four unique symbols with multiple values assigned to them.

The following code example shows how to use a MessageBox to inform the user of a missing entry in a TextBox. This example requires that the method is called from an existing form with a Button and a TextBox on it.

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.Question);

    // If the no button was pressed ... 
    if (result == DialogResult.No)
    {
        // cancel the closure of the form.
        e.Cancel = true;
    }
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft