Event Handler

Friend Sub AddHandlerEx()

Dim application2 As ESRI.ArcGIS.Framework.IApplication = CType(My.ThisApplication, ESRI.ArcGIS.Framework.IApplication)
Dim mxDocument As ESRI.ArcGIS.ArcMapUI.IMxDocument = application2.Document
Dim activeView As ESRI.ArcGIS.Carto.IActiveView = mxDocument.ActiveView
Dim map As ESRI.ArcGIS.Carto.IMap = activeView.FocusMap
‘Step 2: Create an instance of the delegate using the AddressOf operator and add it to
‘the AfterDraw event.
m_ActiveViewEventsSelectionChanged = New ESRI.ArcGIS.Carto.IActiveViewEvents_SelectionChangedEventHandler(AddressOf OnActiveViewEventsSelectionChanged)
‘Step 3: Dynamically associate an event handler to the delegate object.
AddHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).SelectionChanged, m_ActiveViewEventsSelectionChanged

End Sub

Public Sub RemoveHandlerEx()
Dim application2 As ESRI.ArcGIS.Framework.IApplication = CType(My.ThisApplication, ESRI.ArcGIS.Framework.IApplication)
Dim mxDocument As ESRI.ArcGIS.ArcMapUI.IMxDocument = application2.Document
Dim activeView As ESRI.ArcGIS.Carto.IActiveView = mxDocument.ActiveView
Dim map As ESRI.ArcGIS.Carto.IMap = activeView.FocusMap
‘Step 4: Dynamically remove an event handler.
RemoveHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).SelectionChanged, m_ActiveViewEventsSelectionChanged
End Sub

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: