![]() |
This document is archived and information here might be outdated. Recommended version. |
Find a specific tool (or command) in a toolbar and set it to be active.
///<summary>Find a specific tool (or command) in a toolbar and set it to be active.</summary>
///
///<param name="application">An IApplication interface.</param>
///<param name="toolName">A System.String that is the name of the command to return. Example: "esriFramework.HelpContentsCommand"</param>
///
///<remarks>Refer to the EDN document http://edndoc.esri.com/arcobjects/9.1/default.asp?URL=/arcobjects/9.1/ArcGISDevHelp/TechnicalDocuments/Guids/ArcMapIds.htm for a listing of available CLSID's and ProgID's that can be used as the toolName parameter.</remarks>
public void SetToolActiveInToolBar(ESRI.ArcGIS.Framework.IApplication application, System.String toolName)
{
ESRI.ArcGIS.Framework.ICommandBars commandBars=application.Document.CommandBars;
ESRI.ArcGIS.esriSystem.UID commandID=new ESRI.ArcGIS.esriSystem.UIDClass();
commandID.Value=toolName; // example: "esriArcMapUI.ZoomInTool";
ESRI.ArcGIS.Framework.ICommandItem commandItem=commandBars.Find(commandID, false, false);
if (commandItem != null)
application.CurrentTool=commandItem;
}
'''<summary>Find a specific tool (or command) in a toolbar and set it to be active.</summary>
'''
'''<param name="application">An IApplication interface.</param>
'''<param name="toolName">A System.String that is the name of the command to return. Example: "esriFramework.HelpContentsCommand"</param>
'''
'''<remarks>Refer to the EDN document http://edndoc.esri.com/arcobjects/9.1/default.asp?URL=/arcobjects/9.1/ArcGISDevHelp/TechnicalDocuments/Guids/ArcMapIds.htm for a listing of available CLSID's and ProgID's that can be used as the toolName parameter.</remarks>
Public Sub SetToolActiveInToolBar(ByVal application As ESRI.ArcGIS.Framework.IApplication, ByVal toolName As System.String)
Dim commandBars As ESRI.ArcGIS.Framework.ICommandBars=application.Document.CommandBars
Dim commandID As ESRI.ArcGIS.esriSystem.UID=New ESRI.ArcGIS.esriSystem.UIDClass
commandID.Value=toolName ' example: "esriArcMapUI.ZoomInTool"
Dim commandItem As ESRI.ArcGIS.Framework.ICommandItem=commandBars.Find(commandID, False, False)
If Not (commandItem Is Nothing) Then
application.CurrentTool=commandItem
End If
End Sub