Events in the API Reference

AutoCAD Map 3D .NET API

 
Events in the API Reference
 
 
 

For every event, the AutoCAD Map 3D API Reference contains the following:

  • Class definition for the event arguments. The names of these classes usually begin with the event name and end with “EventArgs”. In some cases the event uses System.EventArgs instead of defining a new class.
  • Methods for adding and removing event handlers. The names of these methods begin with “add_” or “remove_”. Do not call these methods directly. Instead use the correct syntax for the language.
  • Type definition for the event handler.
    NoteSome events, such as ProjectModel.BeginClose, use System.EventHandler and System.EventArgs instead of objects derived from them. For details refer to the API reference or the Visual Studio Object Browser.

For example, the ProjectOpened event in the Autodesk.Gis.Map namespace consists of the following:

  • ProjectOpenedEventArgs class
  • add_ProjectOpened method in the MapApplication class
  • remove_ProjectOpened method in the MapApplication class
  • ProjectOpenedEventHandler type
NoteThe actual event name is not used in the API reference. It can always be inferred from the corresponding add_ or remove_ methods.

Example: VB.NET

To define an event handler for the ProjectOpened event, create a subroutine:

Sub handleProjectOpened(ByVal pSender As Object, _
ByVal pArgs As ProjectOpenedEventArgs)
   ' Insert code to handle event
End Sub

To subscribe to the event:

AddHandler mapApp.ProjectOpened, AddressOf handleProjectOpened

To unsubscribe from the event:

RemoveHandler mapApp.ProjectOpened, AddressOf handleProjectOpened

Example: C#

To define an event handler for the ProjectOpened event, create a subroutine:

void handleProjectOpened(Object sender,
ProjectOpenedEventArgs args)
{
   // Insert code to handle event
}

To subscribe to the event:

mapApp.ProjectOpened += new ProjectOpenedEventHandler(
   handleProjectOpened);

To unsubscribe from the event:

mapApp.ProjectOpened -= new ProjectOpenedEventHandler(
   handleProjectOpened);