I have a mapcontrol that includes many elements: text, line. I used this code to add elements into mapcontrol:

 pGraphicsContainer.AddElement(pElement, 0);

I can use zoom button to zoom in/out the mapcontrol, but how can I zoom in/out only seleted elements ?

Is there any buttons for this purpose in Arcgis ?

Thanks and regards,


1 Answer 1


EDIT -- For ArcObjects

You can get the extent of selected graphics using IGraphicsContainerSelect.SelectionBounds. This will return an IEnvelope which you can use to set the extent on your IActiveView.

var graphicsSelect = pGraphicsContainer as IGraphicsContainerSelect;
var extent = graphicsSelect.SelectionBounds;
activeView.Extent = extent;

On the Edit Menu, there is a Zoom to Selected Elements tool.

enter image description here

  • Thanks Darlene, But this require a IMxDocument object to get commandBars, but I only have the IMap (FocusMap of my pagelayout control): myPageLayout.ActiveView.FocusMap How can I do that ? PS: I am programming with Arcobjects/ArcgisEngine in C# Regards, Tai
    – taibc
    Aug 20, 2013 at 3:13
  • @taibc Updated my answer with some ArcObjects sample code.
    – Darlene
    Aug 20, 2013 at 18:45
  • Thank you, I tried but not successfull. And, now, this is not neccessary. Please ignore this
    – taibc
    Aug 23, 2013 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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