Export (0) Print
Expand All
Expand Minimize
1 out of 2 rated this helpful - Rate this topic

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
public enum MessageBoxIcon
public enum MessageBoxIcon
 Member nameDescription
Supported by the .NET Compact FrameworkAsteriskThe message box contains a symbol consisting of a lowercase letter i in a circle. 
ErrorThe message box contains a symbol consisting of white X in a circle with a red background. 
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 FrameworkHandThe message box contains a symbol consisting of a white X in a circle with a red background. 
InformationThe message box contains a symbol consisting of a lowercase letter i in a circle. 
Supported by the .NET Compact FrameworkNoneThe message box contain no symbols. 
Supported by the .NET Compact FrameworkQuestionThe message box contains a symbol consisting of a question mark in a circle. 
StopThe 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. 

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 button1_Click(object sender, System.EventArgs e) {
   if(textBox1.Text == "") {
      MessageBox.Show("You must enter a name.", "Name Entry Error",
         MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
   }
   else {
      // Code to act on the data entered would go here.
   }
}

protected void button1_Click(Object sender, System.EventArgs e)
{
    if (textBox1.get_Text().Equals("")) {
        MessageBox.Show("You must enter a name.", "Name Entry Error",
            MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
    }
    else {
        // Code to act on the data entered would go here.
    } 
} //button1_Click

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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.