This document is archived and information here might be outdated.  Recommended version.


IMxDocument.ActiveView Property (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference (ArcMapUI)  

IMxDocument.ActiveView Property

The active view.

[Visual Basic .NET]
Public Property ActiveView As IActiveView
[C#]
public IActiveView ActiveView {get; set;}

Product Availability

Available with ArcGIS Desktop.

Remarks

This method provides access to the active view.  ArcMap currently supports two types of views, layout view and data view; the view with focus is the active view.   If ArcMap is in layout view, this property returns an IActiveView reference to the PageLayout object.  Alternatively, if ArcMap is in data view, the returned IActiveView reference is to a Map object.  Both the PageLayout and Map objects implement the IActiveView interface.

Note, an ArcMap document may have multiple maps (data frames) in it.  Multiple maps means multiple Map objects.  Any Map in this collection may be set as the active view.  There is typically only one PageLayout object per session of ArcMap.

To determine if the returned reference is to a PageLayout object or a Map, attempt a query interface (QI) to either IPageLayout or IMap.  If you know you want a reference to the focus map, use IMxDocument::FocusMap instead.  Similarly, if you know you want a reference to the page layout, use IMxDocument::PageLayout instead.  This is often the case when you need to refresh the display.  For example, if someone has panned the map and you now need to refresh it, explicitly use IMxDocument::FocusMap which returns a reference to the Map with focus, and then QI for IActiveView.

Use this property to also set the active view programmatically.


See Also

IMxDocument Interface | IActiveView Interface

.NET Snippets

Get MxApplication from ArcMap | Get ActiveView from ArcMap | Get Map from ArcMap | Zoom to Active Layer in TOC

.NET Samples

Curve conversion add-in (Code Files: CurveConversionDockWin) | ViperPin tool (Code Files: ViperPinForm) | Custom UI elements using add-ins (Code Files: ZoomToLayerButton) | ArcGIS Network Analyst extension barrier location editor (Code Files: EditorForm) | Create a command by inheriting from BaseCommand (Code Files: ZoomToLayer) | Create a custom tool (Code Files: DrawGraphicLine) | Create a custom selection extension by extending ArcObjects (Code Files: SelectionTargetComboBox ZoomToLayerMultiItem)

.NET Related Topics

Adjusting feature locations with spatial adjustment | Create a command by inheriting from BaseCommand | Create a custom tool | How to wire custom events using IActiveViewEvents