What does this code do? 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;
}
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...
The time required for a signal to travel to a satellite is called ____________________.
Fill in the blank(s) with the appropriate word(s).
The Chief Information Officer (CIO) wants to protect laptop users from zero day attacks. Which of the following would BEST achieve the CIO's goal?
A. Host based firewall B. Host based IDS C. Anti-virus D. Anti-spyware
InfiniBand can address (interconnect) ____ of devices, using both copper wire and fiber-optic cables.?
A. ?tens B. ?hundreds C. ?thousands D. ?millions
An I/O module that takes on most of the detailed processing burden, presenting a high-level interface to the processor, is usually referred to as an _________.
A. I/O channel B. I/O command C. I/O controller D. device controller