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


IEditEvents.OnCreateFeature Event (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Editor > ESRI.ArcGIS.Editor > Interfaces > IE > IEditEvents Interface > IEditEvents.OnCreateFeature Event
ArcGIS Developer Help

IEditEvents.OnCreateFeature Event

Called when new features are created.

[Visual Basic .NET]
Public Event OnCreateFeature As OnCreateFeatureEventHandler
[C#]
public event OnCreateFeatureEventHandler OnCreateFeature

Product Availability

Available with ArcGIS Desktop.

Remarks

Whenever a new feature is created the OnCreateFeature event is fired. The new feature is passed to all listening clients via the IObject parameter.
[Visual Basic .NET]
'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

See Also

IEditEvents Interface