ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

RefreshTOC

  • Summary
  • Discussion
  • Syntax
  • Code sample

Summary

Refreshes the table of contents.

Discussion

If Python is used to modify the table of contents within the current map document (e.g., change a layer name), the map will not automatically update with the changes. RefreshTOC is only needed if you want to see the table of contents updated.

Syntax

RefreshTOC ()

Code sample

RefreshTOC example

A simple script run from the Python window that demonstrates how to update the Table of Contents and force a refresh to make the change visible.

import arcpy

# Create a MapDocument object from the current map
mxd = arcpy.mapping.MapDocument("CURRENT")

# Update the layer name of the first layer in the Table of Contents
arcpy.mapping.ListLayers(mxd)[0].name = "New Layer Name"

# Refresh the Table of Contents to reflect the change
arcpy.RefreshTOC()

del mxd

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal