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) ' Perform query count Dim value As Integer = 0 value = featureLayer.GetFeatureCount(queryFilter) If value = 0 Then MsgBox("can't find PID") End If ' Flag the new selection activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing) End Sub
Solved! Go to Solution.
If featureSelection.SelectionSet.Count() = 0 Then MsgBox("can't find PID") End If
If featureSelection.SelectionSet.Count() = 0 Then MsgBox("can't find PID") End If