18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

BUILDING APPLICATIONS WITH WINDOWS CONTROLS<br />

Loading map documents into the PageLayoutControl and<br />

MapControl<br />

Individual data layers or preauthored map documents can be loaded into the<br />

MapControl and PageLayoutControl. You can either load the sample map document<br />

provided, or you can load in your own map document. Later you will add a<br />

dialog box to browse to a map document.<br />

1. Select the Form_Load event and enter the following code (if you are using<br />

your own map document, substitute the correct filename):<br />

private void Form1_Load(object sender, System.EventArgs e)<br />

{<br />

// Load a preauthored map document into the PageLayoutControl using<br />

// relative paths.<br />

string fileName =<br />

@"..\..\..\..\..\..\..\..\Data\\<strong>ArcGIS</strong>_<strong>Engine</strong>_<strong>Developer</strong>_<strong>Guide</strong>\Gulf of St.<br />

Lawrence.mxd";<br />

if (axPageLayoutControl1.CheckMxFile(fileName))<br />

{<br />

axPageLayoutControl1.LoadMxFile(fileName,"");<br />

}<br />

}<br />

2. Display the form in design mode and select axPageLayoutControl1 from the<br />

Properties window and display the axPageLayoutControl events. Double-click<br />

on the OnPageLayoutReplaced event to add an event handler to the code<br />

window.<br />

3. In the axPageLayoutControl_OnPageLayoutReplaced event, enter the following<br />

code to load the same map document into the MapControl. The<br />

336 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!