Hi Cynthia,
For your post regarding selecting the feature inside envelope, I think the code below will be useful. It uses ISpatialFilter and IFeatureSelection interface to query and select the points respectively. I have the code in VBA, you might have to modify it as per your requirement. The code is written on button's click event and envelope needs to be selected by tracking a rectangle using cursor. The points inside the envelope are selected and number of selected points is also given in message box.
------------------------
Private Sub UIButtonControl1_Click()
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
Dim pEnv As IEnvelope
Dim pRubber As IRubberBand
Set pRubber = New RubberEnvelope
Dim pActiveView As IActiveView
Set pActiveView = pMxDoc.FocusMap
Set pEnv = pRubber.TrackNew(pActiveView.ScreenDisplay, Nothing)
Dim pSpatialFilter As ISpatialFilter
Set pSpatialFilter = New SpatialFilter
Set pSpatialFilter.Geometry = pEnv
pSpatialFilter.SpatialRel = esriSpatialRelIntersects
Dim lPoints As Long
Dim pLayer As IFeatureLayer
Dim pFeatureCursor As IFeatureCursor
Dim pFeature As IFeature
Dim i As Long
For i = 0 To pMxDoc.FocusMap.LayerCount - 1
If (TypeOf pMxDoc.FocusMap.Layer(i) Is IGeoFeatureLayer) Then
Set pLayer = pMxDoc.FocusMap.Layer(i)
pSpatialFilter.GeometryField = pLayer.FeatureClass.ShapeFieldName
Set pFeatureCursor = pLayer.Search(pSpatialFilter, True)
Set pFeature = pFeatureCursor.NextFeature
Do Until (pFeature Is Nothing)
Select Case pFeature.Shape.GeometryType
Case esriGeometryPoint
lPoints = lPoints + 1
End Select
Set pFeature = pFeatureCursor.NextFeature
Loop
End If
Next i
Dim pFS As IFeatureSelection
Set pFS = pLayer
pFS.SelectFeatures pSpatialFilter, esriSelectionResultNew, False
pActiveView.Refresh
MsgBox "Features Found:" & vbCrLf & lPoints & " Points "
End Sub
-----------------------
Hope this helps.
Regards,
Swapna.