Change Caption of Base Command

2314
10
04-13-2011 09:35 AM
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
I have a tool that inherits BaseCommand.  It's set as a Toggle button to be toggled on when editing and off when not.  When toggled on the caption should read "Stop Editing" and when Off it should read "Start Editing".  The code below worked fine in 9.3.1 but for some reason the caption no longer changes. 

Any ideas?

 Public Overrides Sub OnClick()
        'TODO: Add StartStopEditing.OnClick implementation

        Dim pID As New UID
        Dim pfLayer As IFeatureLayer = Nothing
        Dim pDataSet As IDataset = Nothing
        Dim pMxDoc As IMxDocument = Nothing

        'Start/Stop Editing Sign workspace
        Try
            pID.Value = "esriEditor.Editor"
            _pEditor = m_application.FindExtensionByCLSID(pID)
            pMxDoc = CType(m_application.Document, IMxDocument)
            pfLayer = pMxDoc.FocusMap.Layer(GetIndexNumberOfLayerName(pMxDoc.ActiveView, sLayerName))
            pDataSet = pfLayer.FeatureClass
            If _pEditor.EditState = ESRI.ArcGIS.Editor.esriEditState.esriStateNotEditing Then
                _pEditor.StartEditing(pDataSet.Workspace)
                MyBase.m_caption = "Stop Editing"
                MyBase.m_checked = True
            ElseIf _pEditor.EditState = ESRI.ArcGIS.Editor.esriEditState.esriStateEditing Then
                MyBase.m_caption = "Start Editing"
                MyBase.m_checked = False
                _pEditor.StopEditing(True)
            End If

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
0 Kudos
10 Replies
ChrisFox3
Occasional Contributor III
Hi Andrew,

There is actually another bug related to ICommandItem.Caption property not behaving as expected, NIM072205. This bug is fixed at 10.1 and will be fixed in Service Pack 4 for ArcGIS 10 as well. So at this time there is no workaround for 10, however when Service Pack 4 is released early next year you should be able to use ICommandItem.Caption.
0 Kudos