I want to use the ArcMap Identify-Tool inside a WindowsForm. So I've created a button and added a clickevent:
Private Sub btnIdentify_Click(sender As Object, e As EventArgs) Handles btnIdentify.Click
Dim intObjectID As Integer = lstResults.SelectedValue
Dim pLayer As ILayer2 = pDocument.FocusMap.Layer(0)
DoIdentify(pLayer, intObjectID)
End Sub <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I've also created a sub procdedure similar to the one in the ArcObjects API Reference for .NET
Private Sub DoIdentify(ByVal pLayer As ILayer, ByVal intObjectID As Integer)
If pActiveView Is Nothing Or pLayer Is Nothing Or intObjectID <= 0 Then
Return
End If
Dim pMap As IMap = pActiveView.FocusMap
Dim pIdentifyDialog As IIdentifyDialog = New IdentifyDialogClass()
pIdentifyDialog.Map = pMap
pIdentifyDialog.ClearLayers()
Dim pScreenDisplay As IScreenDisplay = pActiveView.ScreenDisplay
Dim pDisplay As IDisplay = pScreenDisplay
pIdentifyDialog.Display = pDisplay
pIdentifyDialog.AddLayerIdentifyOID(pLayer, intObjectID)
pIdentifyDialog.Show()
End Sub <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
This code works perfectly fine. But I really want to use the new IIdentifyDialog2 Interface. But if I change the code to
Private Sub DoIdentify(ByVal pLayer As ILayer, ByVal intObjectID As Integer)
If pActiveView Is Nothing Or pLayer Is Nothing Or intObjectID <= 0 Then
Return
End If
Dim pMap As IBasicMap2 = pActiveView.FocusMap
Dim pIdentifyDialog As IIdentifyDialog2 = New IdentifyDialogClass()
pIdentifyDialog.BasicMap = pMap
pIdentifyDialog.ClearLayers()
Dim pScreenDisplay As IScreenDisplay3 = pActiveView.ScreenDisplay
Dim pDisplay As IDisplay = pScreenDisplay
pIdentifyDialog.Display = pDisplay
pIdentifyDialog.AddLayerIdentifyOID(pLayer, intObjectID)
pIdentifyDialog.Show()
End Sub <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I get a NullReferenceException at pIdentifyDialog.ClearLayers()
I already tried so many things but somehow I can't get it to work with the new Identify-Tool. Does anyone know the answer?