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

IRelationshipClassEvents Interface (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Geodatabase > ESRI.ArcGIS.GeoDatabase > Interfaces > IR > IRelationshipClassEvents Interface
ArcGIS Developer Help

IRelationshipClassEvents Interface

Provides access to events that occur with a relationship class.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.


Both the RelationshipClass and AttributedRelationshipClass object support IRelationshipClassEvents as an outoing interface to provide events when Relationship objects are created, deleted and changed. A Relationship object supporting IRelationship is passed in to allow you to identify the origin and destination objects as well as the RelationshipClass itself.

Appropriate places to begin listening to IRelationshipClassEvents on a RelationshipClass include from within an Editor Extension or within a Class Extension.  You must specifically identify the RelationshipClass that you wish to listen to events on.

OnCreate is fired if you create a new simple or attributed relationship in one of the following ways :

Note that if you call IRelationshipClass.CreateRelationship on a simple relationship this changes the foreign key inside the destination object to point to the new origin object: i.e the old relationship is deleted in creating the new relationship.  No OnDelete event will be fired corresponding to this implicit deletion. An application may be interested in the details of the relationship that was implicitly deleted. This can be achieved by getting the ISimpleRelationshipChanges interface on the Relationship object passed in to the OnCreate event. This interface has a single property OldOriginKey that the application can use to get the key of the origin object. Any further fetching of the old origin object is up to the application using this key.

OnDelete is fired if you delete a simple or attributed relationship in one of the following ways:

OnChange is fired if you do any of the following:

Note that one can also create and delete relationships implicitly by directly using put_Value to set the origin foreign key field inside the destination object in the case of a simple relationship class.  However, no events in IRelationshipClassEvents will be fired if the user does this (for eg. uses the Table document to directly set foreign key values in the destination object).

An application wishing to track such changes must listen to IObjectClassEvents.OnChange on the destination object class and track changes to the foreign key using IRowChanges.  Note that IObjectClassEvents.OnChange will not be fired on the destination object class in a simple relationship class if the user changes the foreign key value using IRelationshipClass.CreateRelationship or IRelationshipClass.DeleteRelationship

It is important to note that retrieving the origin object or the destination object will issue queries against the database to retrieve the object requrested. This can slow down the process of creating/modifying relationships - This is specially true for attributed relationships.


Name Description
Method OnChange This event is fired when a relationship's attributes are updated.
Method OnCreate This event is fired when a new relationship is created in the relationship class.
Method OnDelete This event is fired when an relationship is deleted from the relationship class.

Classes that implement IRelationshipClassEvents

Classes Description
RelationshipClassEvents Helper coclass for working with the outbound interface on noncreatable relationship classes in VB.
RelationshipClassEventsListener (esriSystemUtility) Helper coclass to provide IRelationshipClassEvents support to the C++ API.

See Also

Relationship Class | RelationshipClass Class | esriRelRole Constants | IRelationshipClassEvents Interface | IRelationshipClassEvents Interface | AttributedRelationship Class | AttributedRelationshipClass Class | ISimpleRelationshipChanges Interface