Can someone tell me what I'm doing wrong, please? I'm just trying to select the first layer for a selection, in ArcMap, and I'm using the SelectMapFeaturesByAttributeQuery snippet, as a starting point.Imports ESRI.ArcGIS.esriSystem
Imports ESRI.ArcGIS.Geometry
Imports ESRI.ArcGIS.Geodatabase
Imports ESRI.ArcGIS.Carto
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'MsgBox(Me.TextBox1.Text)
Dim pMap = My.ArcMap.Document.ActiveView
SelectMapFeaturesByAttributeQuery(pMap, pMap.Layer(0), "PID = '55144133'") <-- something is wrong here
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Public Sub SelectMapFeaturesByAttributeQuery(ByVal activeView As IActiveView, ByVal featureLayer As IFeatureLayer, ByVal whereClause As System.String)
If activeView Is Nothing OrElse featureLayer Is Nothing OrElse whereClause Is Nothing Then
Return
End If
Dim featureSelection As IFeatureSelection = TryCast(featureLayer, IFeatureSelection) ' Dynamic Cast
' Set up the query
Dim queryFilter As IQueryFilter = New QueryFilterClass
queryFilter.WhereClause = whereClause
' Invalidate only the selection cache. Flag the original selection
activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)
' Perform the selection
featureSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultNew, False)
' Flag the new selection
activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)
End Sub
End Class