ArcObjects Component Help  (Core)    

IObjectClassEvents Interface

Provides access to events that occur with an object class.

When To Use

Use IObjectClassEvents for building ClassExtensions when you don't want to rely on catching IEditorEvents such as OnCreate and OnChange. This is handy when you need to implement a geodatabase-level customization that will not be application specific, i.e. dependent upon ArcMap and the Editor extension.

Members

Description
Event OnChange This event is fired when an object's attributes or geometry is updated.
Event OnCreate This event is fired when a new object is created in the object class.
Event OnDelete This event is fired when an object is deleted from the object class.

CoClasses that implement IObjectClassEvents

CoClasses and Classes Description
DimensionInspector A property inspector for dimension features.
FDOGraphicsLayer A FDO graphics layer.
ObjectClassEvents Helper coclass for working with the outbound interface on noncreatable object classes in VB.
RelQueryTable An object that joins two datasets based on common data values.
RouteEventSource Route event source object.
XYEventSource XY event source object.

Remarks

If you are using the OnCreate, OnDelete or OnChange methods in a class extension to validate edit operations, you should not call AbortEditOperation on the workspace if your logic indicates that the edit operation is invalid. Instead, raise an error which will be propagated to the application that is performing the edit on the class.

It is the responsibility of the editing application that receives the error to abort the edit operation. This is especially true when editing with ArcMap. If you call AbortEditOperation from within the class extension, the ArcMap undo/redo edit stack will become out of sync.
The following is an example of how you can raise an appropriate error which will tell ArcMap (or another application) that the edit operation failed and that it should be aborted:

Private Const E_FAIL As Long = -2147467259
Private Sub IObjectClassEvents_OnChange(ByVal obj As esriCore.IObject)
  Dim pFeature As IFeature
  Set pFeature = obj
  
  If "your validation code here" Then
      Err.Raise E_FAIL,,"Invalid feature"
  End If
End Sub

Example

IObjectClassEvents Example