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
Solved! Go to Solution.
dim pMap as IMap = My.ArcMap.Document.ActiveView
public FeatureLayer getLayerByName(String layerName) { FeatureLayer layer = null; try { for (int i = 0; i < iMap.getLayerCount(); i++) { if (iMap.getLayer(i).getName().equalsIgnoreCase(layerName)) { layer = (FeatureLayer) iMap.getLayer(i); break; } } } catch (AutomationException ae) { ae.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // Returns the featurelayer return layer; }
dim pMap as IMap = My.ArcMap.Document.ActiveView