Create a command by inheriting from BaseCommand


PurposeThis command will zoom to the extent of the selected layer and is created by inheriting the BaseCommand class in ESRI.ArcGIS.ADF. This sample contains all the code that was demonstrated in the Create a command by inheriting from BaseCommand walkthrough topic.

Development licensing Deployment licensing
ArcView ArcView
ArcEditor ArcEditor
ArcInfo ArcInfo

How to use

See Using the samples for help on compiling, setting up the debugger, and running the sample (either an exe or dll).

  1. Open and compile the solution.
  2. Start ArcMap and either 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
How to implement custom commands and tools