How do you add a BaseCommand to a custom BaseToolbar as an icon and text?

This is not an Add-In, it's the old way of doing buttons and toolbars even though it's version 10 of ArcMap.

2 Answers 2


I didn't try the solution in the thread below but it looks correct to me: How to show caption and icon for basecommand

Depending on how your toolbar is setup, the check for Enabled() can happen frequently. You may want to add a boolean flag to keep the SetAsIconAndText() function from constantly running.

  • 1
    I think it should probably be set up through NewDocument method of a bland Extension class. (I tried to find an example of this question on the forums but obviously used the wrong search words - nice find!)
    – Vidar
    Feb 14, 2012 at 13:45

You need to create a toolbar class, IToolbarDef, to reference your BaseCommand icons to. Then create a resource bitmap and reference it in your BaseCommand class, see example below:

Public Sub New()

        MyBase.m_category = "Developer Samples"
        MyBase.m_caption = "Export Active View VisualBasic .NET"
        MyBase.m_message = "Exports the Active View using VisualBAsic .NET"
        MyBase.m_toolTip = "Export PDFs"
        MyBase.m_name = Me.GetType().Name + ""

            'load the bitmap resource (the icon for this tool).
            Dim bitmapResourceName As String = Me.GetType().Name + ".bmp"
            MyBase.m_bitmap = New Bitmap(Me.GetType(), bitmapResourceName)
        Catch ex As Exception
            System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap")
        End Try

    End Sub
  • This only shows the icon - but I also need text next to it as well. I think it has something to do with: ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconAndText
    – Vidar
    Feb 9, 2012 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.