Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to ArcGIS and want to implement the Zoom to Selected Features functionality available in Selection menu option (Selection-> Zoom to Selected Features), using C# API.

Is any API available in C# ?

share|improve this question
Are you using ArcObjects? – blah238 Feb 14 '13 at 6:47
i am using ArcMap.Document – DevRaj Feb 14 '13 at 10:09
@DevRaj, This question/anwser is very common and can be found with a simple "arcobjects zoom to selected features c#" google search. What version of arcgis are you using? – artwork21 Feb 14 '13 at 11:51
i am using arcGIS 10.1 – DevRaj Feb 14 '13 at 12:38
So you are using ArcObjects. Please tag your questions appropriately in the future. I have done it for you this time. – blah238 Feb 14 '13 at 15:31

To implement, I would suggest creating an Add-In (in C#) using ArcObjects API. Below are some helpful links to get you started:

At the minimum you will need to install Microsoft Visual Studio 2010 Express and ArcObjects .NET 10.1 SDK.

An alternative would be to develop a python Add-In. This option would entail less code, however you may be more limited on available GIS classes/objects.

As I stated in my comment, a web search should give you some source code to start off with.

share|improve this answer
Thnx for code sample – DevRaj Feb 15 '13 at 6:03

Try this one:

void ZoomToSelectedFeature(IFeature feature)
    IGeometry geometry = feature.Shape;

    IActiveView activeView = ArcMap.Document.ActiveView;
    activeView.Extent = geometry.Envelope;

List<IFeature> GetSelectedFeatures(IFeatureLayer selectedFeature)
    IFeatureSelection featureSelection = selectedFeature as IFeatureSelection;
    ISelectionSet selectionSet = featureSelection.SelectionSet;
    ICursor cursor ;

    selectionSet.Search(null, false, out cursor);

    IFeatureCursor featureCursor = cursor as IFeatureCursor; 
    IFeature feature = featureCursor.NextFeature();
    List<IFeature> features = new List<IFeature>();
    while (feature != null)
        feature = featureCursor.NextFeature();
    return features;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.