ArcObjects Library Reference

MapControl Left and Right Mouse Clicks Snippet

Stub code for using left and right mouse clicks for ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent.

[C#]

///<summary>Stub code for using left and right mouse clicks for ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent.</summary>
/// 
///<param name="e">An ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent.</param>
/// 
///<remarks>e is obtained as the result of the AxMapControl.OnMouseDown event.</remarks>
public void MapControlLeftAndRightMouseClicks(ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
{

  if (e.button == 1) // Left mouse click
  {

	// TODO: Your implementation code.....

  }

  if (e.button == 2) // Right mouse click
  {

	// TODO: Your implementation code.....

  }

}
[Visual Basic .NET]

'''<summary>Stub code for using left and right mouse clicks for ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent.</summary>
''' 
'''<param name="e">An ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent.</param>
''' 
'''<remarks>e is obtained as the result of the AxMapControl.OnMouseDown event.</remarks>
Public Sub MapControlLeftAndRightMouseClicks(ByVal e As ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent)

  If e.button = 1 Then ' Left mouse click

    ' TODO: Your implementation code.....

  End If

  If e.button = 2 Then ' Right mouse click

    ' TODO: Your implementation code.....

  End If

End Sub


Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.AxControls
  • ESRI.ArcGIS.Controls