O'Reilly logo

C# Primer: A Practical Approach by Stanley B. Lippman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

6.5. Implementing the MessageBox Pop-Up Dialog

The MessageBox class allows for the easy generation of a pop-up dialog box. Typically it consists of message text, one or more buttons, and an optional icon such as the information icon pictured in Figure 6.2.

To display the MessageBox dialog, we invoke an instance of its static member function Show(). For example, the following invocation generated the Bad Data Dialog pictured in Figure 6.3:

string messages = "Please enter your name before pressing OK";
string title    = "Bad Data Dialog";

if ( textBox1.Text == string.Empty )
     MessageBox.Show( message, title,
                      MessageBoxButtons.OK,
                      MessageBoxIcon.Warning );

We invoke a four-parameter instance of Show(). The first parameter is the string displayed within ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required