Graphics layers ToolControl


Purpose
This sample demonstrates creating a ToolControl by implementing the IToolControl interface. The ToolControl hosts a drop-down list that displays the names of the graphics layers in the map. The end user can select and activate a graphics layer from the ToolControl. This sample also includes a command that creates and adds a new graphics layer to a map. A ToolbarDef hosts both the ToolControl and the new graphics layer command. The following techniques are covered by this sample:
  • Implementing IToolControl
  • Wiring IActiveViewEvents
  • Creating graphics layer
  • Getting and setting the active graphics layer
  • Implementing IToolbarDef

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. Start Visual Studio and open the solution.
  2. Build the solution.
  3. Open a MapControl or PageLayoutControl application (or ArcMap).
  4. From the ToolbarControl Customize dialog box, double-click the Graphics Layers toolset to add the commands to the ToolbarControl.
  5. Use the graphics layers list to select the active graphics layer and use the New Graphics Layer command to add new graphics layers to the map.

GraphicsLayersListToolCtrl.cs The implementation file of the ToolControl.
GraphicsLayersListCtrl.cs The UserControl, which hosts the graphics layers list.
GraphicsLayersListCtrl.Designer.cs The designer file of the UserControl.
NewGraphicsLayerCmd.cs The implementation file for the New Graphics Layer command.
GraphicsLayersToolbar.cs The toolbar, which hosts the ToolControl and the New Graphics Layer command.
Download the C# files
GraphicsLayersListToolCtrl.vb The implementation file of the ToolControl.
GraphicsLayersListCtrl.vb The UserControl, which hosts the graphics layers list.
GraphicsLayersListCtrl.Designer.vb The designer file of the UserControl.
NewGraphicsLayerCmd.vb The implementation file for the New Graphics Layer command.
GraphicsLayersToolbar.vb The toolbar, which hosts the ToolControl and the New Graphics Layer command.
Download the VB.NET files

Download the files for all languages

See Also:

How to wire ArcObjects .NET events
IToolControl interface




Development licensing Deployment licensing
Engine Developer Kit Engine Runtime
ArcView ArcView
ArcEditor ArcEditor
ArcInfo ArcInfo