MessageBoxIcon Enumeration

 

Specifies constants defining which information to display.

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

Public Enumeration MessageBoxIcon

Member nameDescription
Asterisk

The message box contains a symbol consisting of a lowercase letter i in a circle.

Error

The message box contains a symbol consisting of white X in a circle with a red background.

Exclamation

The message box contains a symbol consisting of an exclamation point in a triangle with a yellow background.

Hand

The message box contains a symbol consisting of a white X in a circle with a red background.

Information

The message box contains a symbol consisting of a lowercase letter i in a circle.

None

The message box contain no symbols.

Question

The 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.

Stop

The message box contains a symbol consisting of white X in a circle with a red background.

Warning

The message box contains a symbol consisting of an exclamation point in a triangle with a yellow background.

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 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

.NET Framework
Available since 1.1
Return to top
Show: