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


Add Map Commands to ToolbarControl Snippet (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference

Add Map Commands to ToolbarControl Snippet

Add Map Commands to ToolbarControl

[C#]
///<summary>Add Map Commands to ToolbarControl.</summary>
///  
///<param name="toolbarControl">An IToolbarControl inferface  to add map commands to.</param>
///   
///<remarks></remarks>
public void AddMapCommandsToToolbarControl(ESRI.ArcGIS.Controls.IToolbarControl toolbarControl)
{
  // Call to add the map commands to the ToolbarControl
  // For example, if a ToolbarControl named axToolbarControl1 exists use the following code:
  // AddMapCommandsToToolbarControl((IToolbarControl)axToolbarControl1.Object);

  toolbarControl.AddToolbarDef("esriControls.ControlsMapNavigationToolbar", -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
  toolbarControl.AddItem("esriControls.ControlsMapIdentifyTool", -1, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
  toolbarControl.AddItem("esriControls.ControlsMapFindCommand", -1, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
  toolbarControl.AddItem("esriControls.ControlsMapHyperlinkTool", -1, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
  toolbarControl.AddItem("esriControls.ControlsMapMeasureTool", -1, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
  toolbarControl.AddItem("esriControls.ControlsLayerListToolControl", -1, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
  toolbarControl.AddItem("esriControls.ControlsLayerTransparencyCommand", -1, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
  toolbarControl.AddItem("esriControls.ControlsMapSwipeTool", -1, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
}
[Visual Basic .NET]
'''<summary>Add Map Commands to ToolbarControl.</summary>
'''  
'''<param name="toolbarControl">An IToolbarControl inferface  to add map commands to.</param>
'''   
'''<remarks></remarks>
Private Sub AddMapCommandsToToolbarControl(ByVal toolbarControl As ESRI.ArcGIS.Controls.IToolbarControl)

  ' Call to add the map commands to the ToolbarControl
  ' For example, if a ToolbarControl named axToolbarControl1 exists use the following code:
  ' AddMapCommandsToToolbarControl(axToolbarControl1.Object)

  toolbarControl.AddToolbarDef("esriControls.ControlsMapNavigationToolbar", -1, False, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly)
  toolbarControl.AddItem("esriControls.ControlsMapIdentifyTool", -1, -1, True, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly)
  toolbarControl.AddItem("esriControls.ControlsMapFindCommand", -1, -1, False, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly)
  toolbarControl.AddItem("esriControls.ControlsMapHyperlinkTool", -1, -1, False, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly)
  toolbarControl.AddItem("esriControls.ControlsMapMeasureTool", -1, -1, False, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly)
  toolbarControl.AddItem("esriControls.ControlsLayerListToolControl", -1, -1, False, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly)
  toolbarControl.AddItem("esriControls.ControlsLayerTransparencyCommand", -1, -1, False, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly)
  toolbarControl.AddItem("esriControls.ControlsMapSwipeTool", -1, -1, False, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly)

End Sub

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Controls
  • ESRI.ArcGIS.SystemUI