Take the 2-minute tour ×

i find a feature by using IFeatureClass.Search then i want to show the feature on the screen.How can i do that ? is there a zoom interface or else ?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Set the Extent of the map to be the envelope of the feature/features see Zooming in on the map Sample in the documentation.

share|improve this answer
Thanks so much four your answer.i was searching for the feature which the geometry type is point.I used IEnvelope.CenterAt() method to change the extent of the map.Thanks again.Greetings... –  cisci Jul 5 '11 at 13:05

You could use IFeature to zoom to the extent of the active view envelope, example below.

Dim pEnv as IEnvelope
    pFCursor = pFClass.Search(pQFilt, True)
                    pFeature = pFCursor.NextFeature
                    If pFeature Is Nothing Then
                        'MsgBox "Check spelling and case", vbCritical + vbExclamation, "State Not Found!"
                        pActView.Extent = pFeature.Shape.Envelope
                        Set pEnv = pActView.Extent
                        pEnv.Expand 1.1, 1.1, True
                        pActView.Extent = pEnv
                    End If


Select the record and zoom to it, example below.

  ' Part 1: Create a cursor of interstates.
            Dim pFeatureLayer As IFeatureLayer

            Dim pFeatureLayer2 As IFeatureLayer
            Dim pFeatureSelection2 As IFeatureSelection = Nothing
            Dim pFc As IFeatureClass
            Dim pQueryFilter As IQueryFilter
            Dim pSelSet As ISelectionSet
            Dim pFCur As IFeatureCursor = Nothing
            Dim player As ILayer
            Dim pEnumLayer As IEnumLayer
            Dim pEnumLayer2 As IEnumLayer = Nothing
            Dim lngFldPDFLink As Int32

            m_pMap2 = m_pMxDoc2.ActiveView.FocusMap
            pEnumLayer = m_pMap2.Layers

            player = pEnumLayer.Next
            Do Until player Is Nothing
                If player.Name = "My Layer" Then
                    pFeatureLayer = CType(player, IFeatureLayer)
                    pFeatSelection = CType(pFeatureLayer, IFeatureSelection)
                End If
                player = pEnumLayer.Next

            ' Select interstates.
            pQueryFilter = New QueryFilter
            pQueryFilter.WhereClause = "FID <> 99999"
            pFeatSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, False)
            ' Create a feature cursor of selected interstates.
            pSelSet = pFeatSelection.SelectionSet
            pSelSet.Search(Nothing, False, pFCur)

            m_pMap2 = m_pMxDoc2.ActiveView.FocusMap
            pEnumLayer2 = m_pMap2.Layers    

'Zoom selected features
                Dim pUID As New UID
                Dim pCmdItem As ICommandItem
                ' Use the GUID of the Save command
                ' or you can use the ProgID
                ' pUID.Value = "esriArcMapUI.MxFileMenuItem"
                pUID.SubType = 3
                pCmdItem = m_app2.Document.CommandBars.Find(pUID)
share|improve this answer

Your Answer


