This document is archived and information here might be outdated.  Recommended version.


How to enable arrow key and mouse wheel navigation of the map display (ArcObjects .NET 10.5 SDK)

How to enable arrow key and mouse wheel navigation of the map display


Summary
This topic illustrates how the MapControl can be configured to allow the arrow keys to be used to pan around the display and the mouse wheel to zoom in and out of the display. Navigation can only take place when the MapControl has focus.

In this topic


About enabling arrow key panning and mouse wheel navigation

Most container forms or dialog boxes use the arrow keys to change control focus and do not pass these key values onto the MapControl. The IMapControl3.KeyIntercept property allows these keys to be intercepted before the container form or dialog box processes them.

Enabling arrow key panning

Do the following steps to enable arrow key panning:
  1. Set the IMapControl3.KeyIntercept property to esriKeyInterceptArrowKeys.
  2. Set the IMapControl4.AutoKeyboardScrolling property to true to enable automatic panning of the display when the arrow keys are intercepted.

Enabling mouse wheel navigation

Do the following steps to enable mouse wheel navigation:
  1. Set the IMapControl3.KeyIntercept property to esriKeyInterceptArrowKeys.
  2. Set the IMapControl4.AutoMouseWheel property to true to enable automatic zooming on the display with the mouse wheel.
See the following code example:
[C#]
private ESRI.ArcGIS.Controls.AxMapControl axMapControl1;

//Allow the MapControl to intercept arrow keys when it has focus.
axMapControl1.KeyIntercept=(int)esriKeyIntercept.esriKeyInterceptArrowKeys;
axMapControl1.AutoKeyboardScrolling=true;
axMapControl1.AutoMouseWheel=true;
[VB.NET]
AxMapControl1 As ESRI.ArcGIS.Controls.AxMapControl

' Allow the MapControl to intercept arrow keys when it has focus.
AxMapControl1.KeyIntercept=esriKeyIntercept.esriKeyInterceptArrowKeys
AxMapControl1.AutoKeyboardScrolling=True
AxMapControl1.AutoMouseWheel=True


See Also:

MapControl class
IMapControl4 interface




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):

Development licensing Deployment licensing
Engine Developer Kit Engine
ArcGIS for Desktop Basic
ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced