Using the PageLayoutControl


SummaryThis topic provides an overview of the PageLayoutControl and highlights working with elements, loading and saving map documents, and printing.

Development licensing Deployment licensing
Engine Developer Kit Engine Runtime
ArcView
ArcEditor
ArcInfo

In this topic


Introducing the PageLayoutControl

The PageLayoutControl corresponds to the layout view of the ArcMap desktop application and encapsulates the PageLayout object. Map documents authored with ArcMap can be loaded into the PageLayoutControl, eliminating the need to programmatically compose the cartography. See the following screen shot of the PageLayoutControl application:
 
 

Loading map documents

The map document can be set at design time through the PageLayoutControl property pages (in development environments that support property page capability), and the PageLayoutControl can be set to link or contain the map document. When linking, the PageLayoutControl will read the map document whenever the PageLayoutControl is created on the container and display the most recent updates to the map document. When containing, the PageLayoutControl will copy the contents of the map document into the PageLayoutControl and will not display any further updates made to the map document from that point on. Containing increases the size of the application executable containing the PageLayoutControl.
 
Alternatively, a map document can be loaded into the PageLayoutControl programmatically using the CheckMxFile method to determine whether the document is valid and the LoadMxFile method to load the map document.
 

Saving map documents

The PageLayoutControl can write map documents (*.mxd) as well as read them. The PageLayoutControl implements the IMxdContents interface that enables the MapDocument object to write the contents of the PageLayoutControl to a new map document. See the following code example:
 

[C#]
IMapDocument mapDocument = new MapDocumentClass();
mapDocument.New(@"C:\Temp\myDocument.mxd");
mapDocument.ReplaceContents((IMxdContents) axPageLayoutControl1.Object);
mapDocument.SetActiveView(axPageLayoutControl1.ActiveView);
mapDocument.Save(true, true);

[VB.NET]
Dim pMapDocument As IMapDocument
pMapDocument = New MapDocumentClass
pMapDocument.New("C:\Temp\myDocument.mxd")
pMapDocument.ReplaceContents(AxPageLayoutControl1.Object)
pMapDocument.SetActiveView(AxPageLayoutControl1.ActiveView)
pMapDocument.Save(True, True)

Managing elements

The PageLayoutControl provides shortcuts to frequently used members, such as GraphicsContainer and AddElement, and helper methods, such as FindElementByName and LocateFrontElement, to manage individual elements in the PageLayout.
 

Printing tasks

The PageLayoutControl provides shortcuts to frequently used members on the PageLayout object, such as Page and Printer, and helper members, such as PrinterPageCount and PrintPageLayout, to assist with printing tasks.
 


See Also:

Controls library overview
Working with the page layout
How to get started with the PageLayoutControl property pages