Do Identify Snippet (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference

Do Identify Snippet

Performs an identify (via the Identify Dialog) on the layers in the Active View.

[C#]
///<summary>Performs an identify (via the Identify Dialog) on the layers in the Active View.</summary>
///
///<param name="activeView">An IActiveView interface</param>
///<param name="x">An System.Int32 in device (screen) coordinates. Example: 300</param>
///<param name="y">An System.Int32 in device (screen) coordinates. Example: 100</param>
/// 
///<remarks></remarks>
public void DoIdentify(ESRI.ArcGIS.Carto.IActiveView activeView, System.Int32 x, System.Int32 y)
{
  if(activeView == null)
  {
    return;
  }
  ESRI.ArcGIS.Carto.IMap map=activeView.FocusMap;
  ESRI.ArcGIS.CartoUI.IIdentifyDialog identifyDialog=new ESRI.ArcGIS.CartoUI.IdentifyDialogClass();
  identifyDialog.Map=map;

  //Clear the dialog on each mouse click
  identifyDialog.ClearLayers();
  ESRI.ArcGIS.Display.IScreenDisplay screenDisplay=activeView.ScreenDisplay;

  ESRI.ArcGIS.Display.IDisplay display=screenDisplay; // Implicit Cast
  identifyDialog.Display=display;

  ESRI.ArcGIS.CartoUI.IIdentifyDialogProps identifyDialogProps=(ESRI.ArcGIS.CartoUI.IIdentifyDialogProps)identifyDialog; // Explicit Cast
  ESRI.ArcGIS.Carto.IEnumLayer enumLayer=identifyDialogProps.Layers;
  enumLayer.Reset();

  ESRI.ArcGIS.Carto.ILayer layer=enumLayer.Next();

  //
  while (!(layer == null))
  {
    identifyDialog.AddLayerIdentifyPoint(layer, x, y);

    layer=enumLayer.Next();
  }
  identifyDialog.Show();
}
[Visual Basic .NET]
'''<summary>Performs an identify (via the Identify Dialog) on the layers in the Active View.</summary>
'''
'''<param name="activeView">An IActiveView interface</param>
'''<param name="x">An System.Int32 in device (screen) coordinates. Example: 300</param>
'''<param name="y">An System.Int32 in device (screen) coordinates. Example: 100</param>
''' 
'''<remarks></remarks>
Public Sub DoIdentify(ByVal activeView As ESRI.ArcGIS.Carto.IActiveView, ByVal x As System.Int32, ByVal y As System.Int32)

  If activeView Is Nothing Then
    Return
  End If

  Dim map As ESRI.ArcGIS.Carto.IMap=activeView.FocusMap
  Dim identifyDialog As ESRI.ArcGIS.CartoUI.IIdentifyDialog=New ESRI.ArcGIS.CartoUI.IdentifyDialogClass
  identifyDialog.Map=map

  'Clear the dialog on each mouse click
  identifyDialog.ClearLayers()
  Dim screenDisplay As ESRI.ArcGIS.Display.IScreenDisplay=activeView.ScreenDisplay

  Dim display As ESRI.ArcGIS.Display.IDisplay=screenDisplay ' Implicit Cast
  identifyDialog.Display=display

  Dim identifyDialogProps As ESRI.ArcGIS.CartoUI.IIdentifyDialogProps=CType(identifyDialog, ESRI.ArcGIS.CartoUI.IIdentifyDialogProps) ' Explicit Cast
  Dim enumLayer As ESRI.ArcGIS.Carto.IEnumLayer=identifyDialogProps.Layers
  enumLayer.Reset()

  Dim layer As ESRI.ArcGIS.Carto.ILayer=enumLayer.Next

  '
  Do While Not (layer Is Nothing)
    identifyDialog.AddLayerIdentifyPoint(layer, x, y)
    layer=enumLayer.Next()
  Loop

  identifyDialog.Show()

End Sub

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