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

How to change the view from layout view to data view using c# code?

share|improve this question
up vote 4 down vote accepted

You should use the IMxDocument.ActiveView Property.

You can use something like this:

IMxDocument mxDoc=(IMxDocument)m_app.Document;
mxDoc.ActiveView = mxDoc.FocusMap ; //if you want to cast to the focused map
share|improve this answer
Great, it's working fine thanks :) – IBRA Dec 10 '12 at 8:02
When i run the code it's work fine but when i want to get back to layout view (not code) the arcMap stop working. and there is no exception. i don't know why. – IBRA Dec 10 '12 at 8:46
@IbrahimSwaiss I'm not sure why, but activating the View is causing the problem. Just use the first two lines. It is working on my system. – Devdatta Tengshe Dec 10 '12 at 9:09
Yes it's now working, and you can use Deactivate() after the activate line, and thank you again for your help :) – IBRA Dec 10 '12 at 9:17
The docs state that you do not need to call Activate() inside ArcMap, it will take care of that automatically. You only need to call Activate in certain situations when working with MapDocument class. – Petr Krebs Dec 10 '12 at 9:24

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.