ArcObjects Library Reference  (Carto)    

esriCarto IFeatureSelection Example

[Visual Basic 6.0]
Public Sub SelFeatures()
  Dim pMxDoc As IMxDocument
  Dim pMap As IMap
  Dim pFeatSel As IFeatureSelection
  Dim pQF As IQueryFilter
  Dim pSelSet As ISelectionSet
  
  Set pMxDoc = Application.Document
  Set pMap = pMxDoc.FocusMap
  Set pFeatSel = pMap.Layer(0)
  
  ' set up query filter with where clause
  Set pQF = New QueryFilter
  pQF.WhereClause = "POP2000 > 200000"
  
  ' perform selection
  pFeatSel.SelectFeatures pQF, esriSelectionResultNew, False
  pFeatSel.SelectionChanged
  pMxDoc.ActiveView.PartialRefresh esriViewGeography, Nothing, Nothing
  
  ' report number of selected features
  Set pSelSet = pFeatSel.SelectionSet
  MsgBox pSelSet.Count
  
End Sub

[Visual Basic .NET, C#, C++]
No example is available for Visual Basic .NET, C#, or C++. To view a Visual Basic 6.0 example, click the Language Filter button Language Filter in the upper-left corner of the page.