How to add your knowledge

Creating Toolbar Items

    Table of contents
    No headers

    To create a toolbar icon, create a public variable of type Autodesk.Map.IM.Forms.ToolBarButton. Override the DialogPlugIn class’s OnInitToolBar event, obtain a reference to the dialog toolbar, and insert the new button using the Add method of the toolbar’s Buttons collection. You can then create an event handler for the new toolbar button and can respond to toolbar events. For example:

    public Autodesk.Map.IM.Forms.ToolBarButton myToolbarButton = 
      new Autodesk.Map.IM.Forms.ToolBarButton();
     
    public override void OnInitToolBar
      (object sender, Autodesk.Map.IM.Forms.Events.ToolBarEventArgs e)
    {
        // Add a new toolbar button to the toolbar of the
        // generic dialogs.
        e.ToolBar.Buttons.Add
          (myToolbarButton,
          "Topobase",
          "My Toolbar Button");
        myToolbarButton3.Click += 
          new EventHandler(myToolbarButton_Click);
    }
     
     
    // Event is raised when the button is clicked.
    private void myToolbarButton_Click
      (object sender, System.EventArgs e)
    {
        // Perform the plugin action here.
        this.Application.MessageBox("Toolbar button clicked");			
    }