Imports ESRI.ArcGIS.esriSystem Imports ESRI.ArcGIS.Geometry Imports ESRI.ArcGIS.Geodatabase Imports ESRI.ArcGIS.Carto Public Class Button1 Inherits ESRI.ArcGIS.Desktop.AddIns.Button Public Sub New() End Sub Protected Overrides Sub OnClick() SelectMapFeaturesByAttributeQuery(My.ArcMap.Document.ActiveView, ??????, "PID = '00000000'") My.ArcMap.Application.CurrentTool = Nothing End Sub Protected Overrides Sub OnUpdate() Enabled = My.ArcMap.Application IsNot Nothing 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
Solved! Go to Solution.
Dim fLayer as IfeatureLayer = ctype(pMap.Layer(0), IFeatureLayer) SelectMapFeaturesByAttributeQuery(pMap.ActiveView, flayer, "PID = '00000000'")
if typeof pMap.Layer(0) is IFeatureLayer then Dim fLayer as IfeatureLayer = ctype(pMap.Layer(0), IFeatureLayer) SelectMapFeaturesByAttributeQuery(pMap.ActiveView, flayer, "PID = '00000000'") End if
Dim fLayer as IfeatureLayer = trycast(pMap.Layer(0), IFeatureLayer) if fLayer isnot Nothing then SelectMapFeaturesByAttributeQuery(pMap.ActiveView, flayer, "PID = '00000000'") end if
Dim featLayerUid As New UIDClass featLayerUid.Value = "{40A9E885-5533-11D0-98BE-00805F7CED21}" 'IFeatureLayer Dim enumLayer As IEnumLayer = pMap.Layers(featLayerUid , True) 'True argument looks at sub layers in a group enumLayer.Reset() Dim layer As ILayer = enumLayer.Next Do While Not (layer Is Nothing) dim fLayer as IFeatureLayer = CType(layer, IFeatureLayer) 'Guaranteed to work since only querying IFeatureLayers. if ctype(fLayer.FeatureClass, IDataset).Name = "Name_I_am_looking_for" then SelectMapFeaturesByAttributeQuery(pMap.ActiveView, fLayer, "PID = '00000000'") exit do end if layer = enumLayer.Next() Loop
Dim fLayer as IfeatureLayer = ctype(pMap.Layer(0), IFeatureLayer) SelectMapFeaturesByAttributeQuery(pMap.ActiveView, flayer, "PID = '00000000'")
if typeof pMap.Layer(0) is IFeatureLayer then Dim fLayer as IfeatureLayer = ctype(pMap.Layer(0), IFeatureLayer) SelectMapFeaturesByAttributeQuery(pMap.ActiveView, flayer, "PID = '00000000'") End if
Dim fLayer as IfeatureLayer = trycast(pMap.Layer(0), IFeatureLayer) if fLayer isnot Nothing then SelectMapFeaturesByAttributeQuery(pMap.ActiveView, flayer, "PID = '00000000'") end if
Dim featLayerUid As New UIDClass featLayerUid.Value = "{40A9E885-5533-11D0-98BE-00805F7CED21}" 'IFeatureLayer Dim enumLayer As IEnumLayer = pMap.Layers(featLayerUid , True) 'True argument looks at sub layers in a group enumLayer.Reset() Dim layer As ILayer = enumLayer.Next Do While Not (layer Is Nothing) dim fLayer as IFeatureLayer = CType(layer, IFeatureLayer) 'Guaranteed to work since only querying IFeatureLayers. if ctype(fLayer.FeatureClass, IDataset).Name = "Name_I_am_looking_for" then SelectMapFeaturesByAttributeQuery(pMap.ActiveView, fLayer, "PID = '00000000'") exit do end if layer = enumLayer.Next() Loop