A.5. Responding to Mouse and Keyboard Activity

You might recall that the Control parent class defines a set of events that allow you to monitor mouse and keyboard activity in a variety of manners. To check this out firsthand, create a new Windows Forms Application project named MouseAndKeyboardEventsApp, rename the initial form to MainWindow.cs (using the Solution Explorer), and handle the MouseMove event using the Properties window. These steps generate the following event handler:

public partial class MainWindow : Form
{
  public MainWindow()
  {
    InitializeComponent();
  }

  // Generated via the Properties window.
  private void MainWindow_MouseMove(object sender, MouseEventArgs e)
  {
  }
}

The MouseMove event works in conjunction with the System.Windows.Forms.MouseEventHandler ...

Get Pro C# 2010 and the .NET 4 Platform, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.