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


Sample: Create a command by inheriting from BaseCommand (ArcObjects .NET 10.4 SDK)

Create a command by inheriting from BaseCommand


PurposeThis command zooms to the extent of the selected layer and is created by inheriting the BaseCommand class in the ESRI.ArcGIS.ADF.Local assembly's ESRI.ArcGIS.ADF namespace. This sample contains all of the code demonstrated in the Create a command by inheriting from BaseCommand walkthrough.

How to use

See How to use ArcGIS samples for help on compiling, setting up the debugger, and running the sample. If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

  1. Open and compile the solution.
  2. Start ArcMap and open a map document with a layer or add a layer to a new map document.
  3. Add the ZoomToLayer command to a toolbar. It will be in the Developer Samples category, with the name of Zoom To Layer C# (C# version) or Zoom To Layer VB .NET (VB .NET version).
  4. Select a layer in the table of contents (TOC).
  5. Click the ZoomToLayer command button to zoom to the extent of the layer selected in the TOC.
CommandInheritingBaseCommand/ZoomToLayer.cs Zoom to the active layer in the TOC.
Download the C# files
CommandInheritingBaseCommand/ZoomToLayer.vb Zoom to the active layer in the TOC.
Download the VB.NET files

Download the files for all languages

See Also:

Walkthrough: Create a command by inheriting from BaseCommand
Creating commands and tools




Development licensing Deployment licensing
ArcGIS for Desktop Basic ArcGIS for Desktop Basic
ArcGIS for Desktop Standard ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced ArcGIS for Desktop Advanced