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


How to get started with the PageLayoutControl property pages (ArcObjects .NET 10.5 SDK)

How to get started with the PageLayoutControl property pages


Summary
This topic shows how to get started with the PageLayoutControl in conjunction with the ToolbarControl, TOCControl, Control Commands, and the LicenseControl by using the property pages supplied with each control. Following the steps in this topic produces a fully functional application in only a few minutes.

In this topic


Getting started with the PageLayoutControl property pages 

To get started with the PageLayoutControl property pages, follow these steps to create a project in Visual Studio:
  1. Start Microsoft Visual Studio.
  2. From the File menu, select New, and click Project. The New Project dialog box opens.
  3. Under Project types, select either Visual Basic or Visual C# (depending on the language you're using), then select Windows Forms Application from under Templates to create a Visual Basic Windows application or a Visual C# Windows application, respectively.
  4. Name the project, click Browse to navigate to a location to save the project, then click OK.
  5. In the Project window, click View, and click Toolbox to open the toolbox in Visual Studio.
  6. In the toolbox, click the ArcGIS Windows Forms tab to show the controls in the following illustration:

Adding controls to the form

To add controls to the form, perform the following steps:
  1. Click the PageLayoutControl icon in the toolbox. On the form, click and drag from one corner to the opposite corner to place the PageLayoutControl. Alternatively, double-click the PageLayoutControl icon in the toolbox to automatically place the PageLayoutControl on the form. Follow the same procedure to add the TOCControl, ToolbarControl, and LicenseControl icons to the form. Rearrange the control positions and resize the controls to look similar to the following:

  1. Right-click the PageLayoutControl and click Properties. The Properties dialog box opens.
  2. Click the General tab, and click the Open folder button next to the Map Document field. See the following screen shot:



    The Select Map Document dialog box opens.
  1. Navigate to a folder containing the map document, select the map document, and click Open.
  2. On the Properties dialog box, click Apply to link the map document to the PageLayoutControl, then click OK to close the Properties dialog box.
  3. Right-click the TOCControl and click Properties. The TOCControl Properties dialog box opens.
  4. Click the General tab, select AxPageLayoutControl1 from the Buddy Control drop-down list, then click Apply. See the following screen shot:

  1. Click OK to close the TOCControl Properties dialog box.
  2. Right-click the ToolbarControl and click Properties. The ToolbarControl Properties dialog box opens.
  3. Click the General tab, select AxPageLayoutControl1 from the Buddy Control drop-down list, then click Apply.
  4. Click the Items tab on the ToolbarControl Properties dialog box and click Add. The Controls Commands dialog box opens.
  5. Click the Toolsets tab, and either double-click the PageLayout toolset, or drag and drop the toolset onto the Properties dialog box with the Items tab selected. Repeat to add any other commands, toolsets, menus, or palettes, then click Close. See the following screen shot:

  1. With the Items tab still selected on the ToolbarControl Properties dialog box, click to choose an item. Drag and drop the selected item to a new position on the ToolbarControl (selection is indicated by the black outline around the item), or drag and drop an item from the ToolbarControl to remove it. Right-click an item to delete it or set its style, group, or group spacing, then click Apply. See the following screen shot:

  1. Click OK to close the ToolbarControl Properties dialog box.
  2. Load the appropriate version of ArcGIS Engine for Windows at the entry point to your application. See the following code example:
[C#]
using ESRI.ArcGIS;
...[STAThread] static void Main()
{
    if (!RuntimeManager.Bind(ProductCode.Engine))
    {
        MessageBox.Show(
            "Unable to bind to ArcGIS runtime. Application will be shut down.");
        return ;
    }

    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new MainForm());
}
[VB.NET]
Imports ESRI.ArcGIS
...

Private Sub MyApplication_Startup(ByVal sender As Object, _
                                  ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) _
                                  Handles Me.Startup
    If Not ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Engine) Then
        MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.")
        e.Cancel=True 'Abort application start up.
    End If
End Sub
  1. Right-click the LicenseControl and click Properties. The LicenseControl Properties dialog box opens.
  2. Click the License tab, then select the ArcGIS Engine, ArcGIS for Desktop Basic, ArcGIS for Desktop Standard, and ArcGIS for Desktop Advanced check boxes under Products.
  3. Select the Shutdown this application if the selected licenses are not available check box, then click Apply. See the following screen shot:


  4. Click OK to close the LicenseControl Properties dialog box.
  5. To build the solution, select it from the Build menu.
  6. Click Start Debugging from the Debug menu to run the application. Toggle layer visibility by interacting with the check boxes on the TOCControl. Select a tool on the ToolbarControl and use it to interact with the PageLayoutControl. See the following screen shot:



See Also:

PageLayoutControl class




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
Engine Developer Kit Engine
ArcGIS for Desktop Basic
ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced