IEditEvents when editing tables

1677
1
Jump to solution
06-22-2016 10:35 AM
TheodoreRakel
Occasional Contributor

I can use the IEditEvents to be notified of edits to features, but is there some way to be notified when the user in ArcMap makes changes to a table?  For example, if the user uses the Attributes window to update a field in a table, I would like to know that an update has happened.  I don't see IEditEvents_OnChangeFeature firing when I update an attribute in a table, which makes sense because it's not a feature that is changing.  What I'm looking for is something like IEditEvents_OnAnyChange, just so I know that the user is doing some kind of insert update or delete.  I'm using ArcMap 10.2.1.

1 Solution

Accepted Solutions
JeffMatson
Occasional Contributor III

You can use IObjectClassEvents:

IObjectClassEvents Example

Just change it to use IStandAloneTable and ITable instead of IFeatureClass:

Private WithEvents ObjectClassEvents As ObjectClassEvents

Public Sub initEvents()

  Dim pMxdoc As IMxDocument

  Set pMxdoc = Application.Document

  Dim satColl As IStandaloneTableCollection

  Set satColl = pMxdoc.FocusMap

  Dim sat As IStandaloneTable

  Set sat = satColl.StandaloneTable(0)

  Dim t As ITable

  Set t = sat.Table

' Dim pFeatureLayer As IFeatureLayer

'  Dim pLayer As ILayer

'  Dim pFeatureClass As IFeatureClass

'  Set pLayer = pMxdoc.FocusMap.Layer(0)

'  Set pFeatureLayer = pLayer

'  Set pFeatureClass = pFeatureLayer.FeatureClass

  Dim pObjectClass As IObjectClass

'  Set pObjectClass = pFeatureClass

  Set pObjectClass = t

  Set ObjectClassEvents = pObjectClass

End Sub

Private Sub ObjectClassEvents_OnChange(ByVal obj As IObject)

  MsgBox "OnChange for: " & obj.OID

End Sub

Private Sub ObjectClassEvents_OnCreate(ByVal obj As IObject)

  MsgBox "OnCreate for: " & obj.OID

End Sub

Private Sub ObjectClassEvents_OnDelete(ByVal obj As IObject)

  MsgBox "OnDelete for: " & obj.OID

End Sub

View solution in original post

1 Reply
JeffMatson
Occasional Contributor III

You can use IObjectClassEvents:

IObjectClassEvents Example

Just change it to use IStandAloneTable and ITable instead of IFeatureClass:

Private WithEvents ObjectClassEvents As ObjectClassEvents

Public Sub initEvents()

  Dim pMxdoc As IMxDocument

  Set pMxdoc = Application.Document

  Dim satColl As IStandaloneTableCollection

  Set satColl = pMxdoc.FocusMap

  Dim sat As IStandaloneTable

  Set sat = satColl.StandaloneTable(0)

  Dim t As ITable

  Set t = sat.Table

' Dim pFeatureLayer As IFeatureLayer

'  Dim pLayer As ILayer

'  Dim pFeatureClass As IFeatureClass

'  Set pLayer = pMxdoc.FocusMap.Layer(0)

'  Set pFeatureLayer = pLayer

'  Set pFeatureClass = pFeatureLayer.FeatureClass

  Dim pObjectClass As IObjectClass

'  Set pObjectClass = pFeatureClass

  Set pObjectClass = t

  Set ObjectClassEvents = pObjectClass

End Sub

Private Sub ObjectClassEvents_OnChange(ByVal obj As IObject)

  MsgBox "OnChange for: " & obj.OID

End Sub

Private Sub ObjectClassEvents_OnCreate(ByVal obj As IObject)

  MsgBox "OnCreate for: " & obj.OID

End Sub

Private Sub ObjectClassEvents_OnDelete(ByVal obj As IObject)

  MsgBox "OnDelete for: " & obj.OID

End Sub

View solution in original post