The correct way:
Using an extension:
Here is the Class.vb called in the esriaddinx:
[HTML]
Imports System.Windows.Forms
Imports ESRI.ArcGIS.esriSystem
Imports ESRI.ArcGIS.Framework
Public Class YOUREXTENSIONClassName
Inherits ESRI.ArcGIS.Desktop.AddIns.Extension
'Not needed for this example
' Private c_mainMenuID As String = "{1E739F59-E45F-11D1-9496-080009EEBECB}" ' Main menubar
Public Sub New()
End Sub
Protected Overrides Sub OnStartup()
WireDocumentEvents()
End Sub
Protected Overrides Sub OnShutdown()
End Sub
Private Sub WireDocumentEvents()
AddHandler My.ArcMap.Events.NewDocument, AddressOf ArcMapNewDocument
AddHandler My.ArcMap.Events.OpenDocument, AddressOf ArcMapOpenDocument
End Sub
Private Sub ArcMapNewDocument()
Try
SetAsIconAndText(Your UID OR ClassID value, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleTextOnly )
Catch ex As Exception
MessageBox.Show(ex.Message & vbNewLine & "Details: " & ex.StackTrace, "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
End Try
End Sub
Private Sub ArcMapOpenDocument()
Try
SetAsIconAndText(Your UID OR ClassID value, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleTextOnly )
Catch ex As Exception
MessageBox.Show(ex.Message & vbNewLine & "Details: " & ex.StackTrace, "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
End Try
End Sub
Public Sub SetAsIconAndText(ByVal UIDValue As String, ByVal CommandStyle As ESRI.ArcGIS.SystemUI.esriCommandStyles)
'control text or Text and icon or icon only
Dim pUID As New UID
pUID.Value = UIDValue 'YOUR COMMAND BUTTON UID VALUE OR ButtonID name in esriaddinx file of that Addin.
Dim pCommandItem As ESRI.ArcGIS.Framework.ICommandItem
pCommandItem = My.ArcMap.Application.Document.CommandBars.Find(pUID, True, False)
pCommandItem.Style = CommandStyle
End Sub
End Class
[/HTML]