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 ACTIVEX<br />

4. Run the application. Right-click the PageLayoutControl display area to display<br />

the popup menu, and navigate around the page layout.<br />

Controlling label editing in the TOCControl<br />

By default, the TOCControl allows users to automatically toggle the visibility of<br />

layers and to change map and layer names as they appear in the table of contents.<br />

You will add code to prevent users from editing a name and replacing it with an<br />

empty string.<br />

1. Add the following code to the beginning of the Form_Load event to trigger<br />

the TOCControl label editing events.<br />

Private Sub Form_Load()<br />

' Set label editing to manual.<br />

TOCControl1.LabelEdit = esriTOCControlManual<br />

' Add generic commands…<br />

End Sub<br />

2. Add the following code to the TOCControl1_OnEndLabelEdit event.<br />

Private Sub TOCControl1_OnEndLabelEdit(ByVal x As Long, ByVal y As Long,<br />

ByVal newLabel As String, CanEdit As Boolean)<br />

' If the new label is an empty string, then prevent the edit.<br />

If Trim(newLabel) = "" Then CanEdit = False<br />

End Sub<br />

3. Run the application. To edit a map, layer, heading, or legend class label in the<br />

TOCControl, click it once, and click it a second time to invoke label editing.<br />

Chapter 6 • <strong>Developer</strong> scenarios • 291

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

Saved successfully!

Ooh no, something went wrong!