This document is archived and information here might be outdated. Recommended version. |
Called when new features are created.
[Visual Basic .NET] Public Event OnCreateFeature As OnCreateFeatureEventHandler
[C#] public event OnCreateFeatureEventHandler OnCreateFeature
'Cannot use WithEvents because the outbound interface is not the default interface
Private m_editEvents As IEditEvents_Event
Private m_editor As IEditor
'Declare the delegate
Private dCreateFeature As IEditEvents_OnCreateFeatureEventHandler
Public Sub Events()
Dim editorUID As New UID
Dim m_editor As IEditor
editorUID.Value = "esriEditor.editor"
'Get a reference to application thru hook parameter of OnCreate.
m_editor = m_application.FindExtensionByCLSID(editorUID)
m_editEvents = m_editor
'Create an instance of the delegate, add it to CreateFeature Event
dCreateFeature = New IEditEvents_OnCreateFeatureEventHandler _
(AddressOf OnCreateFeature)
AddHandler m_editEvents.OnCreateFeature, dCreateFeature
End Sub
'Event handler must have the same signature as the event delegate.
Private Sub OnCreateFeature(ByVal obj As ESRI.ArcGIS.Geodatabase.IObject)
'Do Something in responce to the event.
End Sub
Set the event object variable to nothing when the class is destructed to avoid circular reference problems.
..
m_editEvents = Nothing
m_editor = Nothing
RemoveHandler m_editEvents.OnCreateFeature, dCreateFeature
dCreateFeature = Nothing
End Sub