I want listen to Edit Session in ArcMap. But every time when i click on my button in ArcMap, Applicaation crash down. If i debug, it stopped at AddHandler Events.OnStartEditing, AddressOf Events_OnStartEditing under Sub Button1.
Error: Task In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user. ESRI.ArcGIS.Editor.IEditTask
Code:
Imports System.Runtime.InteropServices
Imports ESRI.ArcGIS.esriSystem
Imports ESRI.ArcGIS.Editor
Imports ESRI.ArcGIS.Desktop.AddIns
Imports ESRI.ArcGIS.Geodatabase
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.Framework
Imports ESRI.ArcGIS.ArcMap
Imports ESRI.ArcGIS.SystemUI
Public Class Button1
Inherits ESRI.ArcGIS.Desktop.AddIns.Button
Public Sub New()
End Sub
Protected Overrides Sub OnUpdate()
Enabled = My.ArcMap.Application IsNot Nothing
End Sub
Protected Overrides Sub OnClick()
AddHandler Events.OnStartEditing, AddressOf Events_OnStartEditing
AddHandler Events.OnStopEditing, AddressOf Events_OnStopEditing
End Sub
Private ReadOnly Property MyEditor() As IEditor
Get
Dim m_editor As IEditor
Dim editorUid As New UID()
editorUid.Value = "esriEditor.Editor"
m_editor = TryCast(My.ArcMap.Application.FindExtensionByCLSID(editorUid), IEditor)
Return TryCast(m_editor, IEditor)
End Get
End Property
Private ReadOnly Property Events() As IEditEvents_Event
Get
Dim m_editorEvents As IEditEvents_Event = TryCast(MyEditor, IEditEvents_Event)
Return TryCast(m_editorEvents, IEditEvents_Event)
End Get
End Property
Private Sub Events_OnStartEditing()
MsgBox("you are now editing")
End Sub
Private Sub Events_OnStopEditing()
MsgBox("You will stop editing")
End Sub
End Class