AnsweredAssumed Answered

Change caption, icon, tooltip for Add-in button in program

Question asked by juq on Jun 26, 2013
Latest reply on Jul 2, 2013 by juq
I'm trying to change the icon, caption and tooltip of an button in my custom toolbar. I'm using the add-in process inside Visual Studio.

Ideally I don't want an icon, just the text "English" or "Spanish" to appear on the toolbar depending on what the user clicks. If I can't have the text then an icon that can alternate between 2 different choices would be ok.

If I try to change the FaceID, ToolTip or Caption ArcMap crashes. I can get the contextHelpItem.Name property so I know I'm getting the correct button and toolbar.

ArcGIS 10.1, Visual Studio 2010, VB.net

         Dim documentBars As ICommandBars = m_Application.Document.CommandBars Dim barID As UID = New UIDClass barID.Value = "BGC_Engineering_Inc_BGCLayout_Tool_v4_BGC_Layout_Tool" '"{ebecdd6c-d4da-4523-b478-aab7f940b87e}" Dim barItem As ICommandItem = documentBars.Find(barID, False, False) If Not (barItem Is Nothing) Then ' AndAlso barItem.Type = ESRI.ArcGIS.Framework.esriCommandTypes.esriCmdTypeToolbar Then     Dim commandBar As ICommandBar = CType(barItem, ICommandBar)     Dim commandID As ESRI.ArcGIS.esriSystem.UID = New ESRI.ArcGIS.esriSystem.UIDClass     commandID.Value = "BGC_Engineering_Inc_BGCLayout_Tool_version_4_btn_Language"     Dim contextHelpItem As ICommandItem = commandBar.Find(commandID, False)     If Not contextHelpItem Is Nothing Then         ' get bitmap         'Dim newIcon As System.Drawing.Bitmap         If g_bEnglish = True Then            'newIcon = New System.Drawing.Bitmap(Me.GetType(), "Images/btn_Language_en.bmp")             'contextHelpItem.FaceID = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIPictureDispFromBitmap(newIcon)             'contextHelpItem.Style = esriCommandStyles.esriCommandStyleTextOnly             'contextHelpItem.Caption = "English"             contextHelpItem.Tooltip = "Now English"         Else             'newIcon = New System.Drawing.Bitmap(Me.GetType(), "Images/btn_Language_es.bmp")             'contextHelpItem.FaceID = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIPictureDispFromBitmap(newIcon)             'contextHelpItem.Style = esriCommandStyles.esriCommandStyleTextOnly             'contextHelpItem.Caption = "Spanish"             contextHelpItem.Tooltip = "Now Spanish"         End If     End If End If

Outcomes