ArcObjects Library Reference  (Editor)    

Editor_Example

[Visual Basic 6.0]

The following examples show one way to acquire a reference to one of the Editor's interfaces with Visual Basic for Applications and Visual Basic respectively.

When using VBA, you are provided a hook to the ArcMap application referenced by an Application object. You need only create a reference to the Editor CLSID:

 Dim pEditor As IEditor
 Dim pID as New UID
 pID = "esriEditor.Editor"
 Set pEditor = Application.FindExtensionByCLSID(pID)

With Visual Basic you need to hook into the ArcMap application. You can do this by implementing the ICommand interface. The ArcMap application passes an object to your command using the ICommand_OnCreate event. Below is an example of how you can reference the editor when that event is raised.

Private Sub ICommand_OnCreate(ByVal hook As Object)
  Dim pApplication as IApplication
  Dim pEditor as IEditor
  Set pApplication = hook
  Set pEditor = pApplication.FindExtensionByName("ESRI Object Editor")
End Sub
 

[C#]

public override void OnCreate(object hook)
{
 m_application = (IApplication)hook;
            
  
}


public IEditor getEditor()
{
 //get editor extension
 UID editorUID = new UIDClass();
 editorUID.Value = "esriEditor.Editor";
 IEditor editor = m_application.FindExtensionByCLSID(editorUID) as IEditor;
 return editor;
}


[Visual Basic .NET, C++]
No example is available for Visual Basic .NET or C++. To view a Visual Basic 6.0 or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.