What does this code do? Consider the example in Fig. 21.27. Suppose we change the MouseMove event handler to the code below. What happens when the user moves the mouse? Assume that the lblDis- play Label has been placed on the Form.
private void FrmPainter_MouseMove(
object sender, System.Windows.Forms.MouseEventArgs e )
{
lblDisplay.Text = "I'm at " + e.X + ", " + e.Y + ".";
} // end method FrmPainter_MouseMove
The Label continuously displays the mouse pointer’s current position on the Form.
The complete code reads:
// Painter.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace MousePointer
{
///
/// Summary description for FrmPainter.
///
public class FrmPainter : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblPosition;
private System.Windows.Forms.Label lblDisplay;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public FrmPainter()
{
//
// 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 FrmPainter() );
}
// displays the mouse's current x and y coordinates
private void FrmPainter_MouseMove(
object sender, System.Windows.Forms.MouseEventArgs e )
{
lblDisplay.Text = "I'm at " + e.X + ", " + e.Y + ".";
} // end method FrmPainter_MouseMove
} // end class FrmPainter
}

Computer Science & Information Technology
You might also like to view...
Having selected text to format, you can identify formatting options quickly by accessing the:
A) Format tab. B) Paragraph Dialog Box Launcher. C) Quick Access Toolbar. D) Mini toolbar.
Computer Science & Information Technology
A ____ is also an identifier consisting of an IP address and port number, such as 172.16.0.1:80.
A. socket B. route C. domain name D. URL
Computer Science & Information Technology
An Excel file is called a ________
A) document B) database C) presentation D) workbook
Computer Science & Information Technology
An ____ cable is typically orange, with black rings around the cable every 2.5 meters.
A. RG-10 B. RG-11 C. RG-12 D. RG-13
Computer Science & Information Technology