Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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


share|improve this question
add comment

1 Answer

up vote 3 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 :) –  RASHOMON 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. –  RASHOMON Dec 10 '12 at 8:46
1  
@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 :) –  RASHOMON Dec 10 '12 at 9:17
2  
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
show 1 more comment

Your Answer

 
discard

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.