Using the TOCControl


In this topic


About using the TOCControl

The TOCControl (table of contents control) works in conjunction with a buddy control, displaying the maps, layers, and symbology contained in the buddy. The buddy control can be a MapControl, PageLayoutControl, GlobeControl, or SceneControl. The buddy control can be set at design time through the TOCControl property editor (in development environments that support property page capability) or programmatically using the setBuddyControl() method. See the following screen shot:
See the following code example:
[Java]
tocControl.setBuddyControl(mapControl);
The TOCControl implements the ITOCBuddy interface and can fire methods on the ITOCBuddyEvents interface. The TOCControl uses the buddy control to show an interactive Catalog tree of its map, layer, and symbology contents and synchronizes its contents with its buddy. For example, if the TOCControl has a MapControl as its buddy, and a map layer is removed from the MapControl, the map layer is also removed from the TOCControl. Likewise, if the user interacts with the TOCControl to clear a map layer's visibility, the layer will not be visible in the MapControl.
Each layer's check box in the TOCControl shows in one of the following ways, depending on the layer's state:
Layer that is visible
Layer that is not visible
Layer that is visible at certain scales (2D) or altitudes (3D)
Broken layer whose data cannot be displayed

Layer drag and drop

The TOCControl can support dragging and dropping of layers in the control provided the ITOCControlDefault.setEnableLayerDragDrop() method is set to true. Layers can be moved or copied (by pressing Ctrl) as follows:

Selected item

An item can be selected in the TOCControl interactively by the user when the TOCControl is clicked or programmatically using the ITOCControlDefault.selectItem() method. The ITOCControlDefault.getSelectedItem() method returns the selected item. See the following code example:
[Java]
IBasicMap map[] = new Map[1];
ILayer layer[] = new FeatureLayer[1];
Object legendGroup[] = new Object[1];
Object index[] = new Object[1];
int item[] = new int[1];
tocBean.getSelectedItem(item, map, layer, legendGroup, index);
if (item[0] == esriTOCControlItem.esriTOCControlItemLayer)
    System.out.println("Map: " + map[0].getName() + " Data Frame Name: " +
        layer[0].getName());


See Also:

Controls library overview
How to set TOCControl properties




Development licensingDeployment licensing
Engine Developer KitEngine
ArcGIS for Desktop Basic
ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced