What is the result of the following code? Assume the Form contains a MainMenu con- trol, with a MenuItem named mnuitmColor. Also assume the Form contains a Label called lblMystery.
private void mnuitmColor_Click( object sender, System.EventArgs e )
{
ColorDialog dlgColorDialog = new ColorDialog();
DialogResult result;
dlgColorDialog.FullOpen = true;
result = dlgColorDialog.ShowDialog();
if ( result == DialogResult.Cancel )
{
return;
}
1 lblMystery.BackColor = dlgColorDialog.Color;
} // end method mnuitmColor_Click
When this event handler executes, the Color dialog is displayed. If the user chooses a color, that color is assigned to the BackColor of lblMystery. If the dialog’s Cancel Button is clicked, the dialog closes and this event handler terminates. The complete code reads:
// ColorChanger.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace ColorChanger
{
///
/// Summary description for FrmColorChanger.
///
public class FrmColorChanger : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mnuMainMenu;
private System.Windows.Forms.MenuItem mnuitmForm;
private System.Windows.Forms.MenuItem mnuitmColor;
private System.Windows.Forms.Label lblMystery;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public FrmColorChanger()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent
// call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
// Windows Form Designer generated code
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run( new FrmColorChanger() );
}
// changes the Form's color
private void mnuitmColor_Click(
object sender, System.EventArgs e )
{
ColorDialog dlgColorDialog = new ColorDialog();
DialogResult result;
dlgColorDialog.FullOpen = true;
result = dlgColorDialog.ShowDialog();
if ( result == DialogResult.Cancel )
{
return;
}
lblMystery.BackColor = dlgColorDialog.Color;
} // end method mnuitmColor_Click
} // end class FrmColorChanger
}

You might also like to view...
Bold and underlining are the two recommended formatting attributes for adding emphasis to Web page text.
Answer the following statement true (T) or false (F)
The last line, or End Sub, indicating the end of the Sub procedure is also referred to as the procedure ____.
A. closer B. end point C. footer D. period
A simple text file is called a(n) ____ file.
A. sequential B. dynamic C. archival D. encoded
In a Windows system, a container that holds user accounts and defines the capabilities of its members is called a(n) ____________________.
Fill in the blank(s) with the appropriate word(s).