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


Statements - Use a Tool in a Windows Form Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Statements - Use a Tool in a Windows Form Snippet

Connect a tool embedded in a Windows Form with the ArcGIS Application Framework.

[C#]
//<-- Snippet Start -->
// DESCRIPTION:
// Connect a tool embedded in a Windows Form with the ArcGIS Application Framework.
 
ESRI.ArcGIS.esriSystem.IUID UIDCls=new ESRI.ArcGIS.esriSystem.UIDClass(); 
UIDCls.Value="Application_Root_Namespace.Your_COM_Class_Tool"; 
ESRI.ArcGIS.Framework.ICommandItem commandItem=m_application.Document.CommandBars.Find(UIDCls,false,false); 

if (commandItem == null) 
{ 
 return; 
} 

m_application.CurrentTool=commandItem;

//<-- Snippet End -->
[Visual Basic .NET]
'<-- Snippet Start -->
' DESCRIPTION:
' Connect a tool embedded in a Windows Form with the ArcGIS Application Framework.

Dim UIDCls As ESRI.ArcGIS.esriSystem.IUID=New ESRI.ArcGIS.esriSystem.UIDClass
UIDCls.Value="Application_Root_Namespace.Your_COM_Class_Tool"
Dim commandItem As ESRI.ArcGIS.Framework.ICommandItem=m_application.Document.CommandBars.Find(UIDCls)

If commandItem Is Nothing Then
  Exit Sub
End If

m_application.CurrentTool=commandItem

'<-- Snippet End -->

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