Called when the extension is loaded.

Namespace:  ESRI.ArcGIS.Desktop.AddIns

Assembly:  ESRI.ArcGIS.Desktop.Addins (in ESRI.ArcGIS.Desktop.Addins.dll) Version: 10.0.0.0 (10.0.0.0)

Syntax

C#
protected virtual void OnStartup()
Visual Basic (Declaration)
Protected Overridable Sub OnStartup
Visual C++
protected:
virtual void OnStartup()

Remarks

When creating a custom extension, override the OnStartup method to perform some action when the extension gets loaded.

Examples

The code below shows an extension class that displays a message box when a new document is created.
CopyC#
protected override void OnStartup()
{
  ArcMap.Events.OpenDocument += new ESRI.ArcGIS.ArcMapUI.IDocumentEvents_OpenDocumentEventHandler(Events_OpenDocument);
}

void Events_OpenDocument()
{
  System.Windows.Forms.MessageBox.Show("Opening a document");
}
CopyVB.NET
Protected Overloads Overrides Sub OnStartup()
  AddHandler ArcMap.Events.OpenDocument, AddressOf Events_OpenDocument
End Sub

Private Sub Events_OpenDocument()
  System.Windows.Forms.MessageBox.Show("Opening a document")
End Sub

See Also