How can the enable-state of a AddIn-Button be influenced on start of ArcMap? My button should be disabled on startup of ArcMap and than turned enabled when the Edit-session is started. In ArcGIS 9.3 this was quite simple:

public override bool Enabled
     editor = (ESRI.ArcGIS.Editor.IEditor)m_application.FindExtensionByName("ESRI Object Editor");
     if (editor.EditState == ESRI.ArcGIS.Editor.esriEditState.esriStateEditing)
         return true;
     return false;

Any suggestions?


If the "onDemand" in the xml config is set to false ...

<Button id="Microsoft_ArcMapAddin1_ArcGISAddin1" onDemand="false" 
                class="ArcGISAddin1" message="Add-in command generated by Visual Studio project wizard."
                caption="My Button" tip="Add-in command tooltip." 
                category="Add-In Controls" image="Images\ArcGISAddin1.png" />

The tool gets instantiated when Arcmap starts up (instead of when the first time the button is clicked), resulting in the OnUpdate being called every 300 or so millisecs ...

protected override void OnUpdate()
    IEditor m_Editor = (ESRI.ArcGIS.Editor.IEditor)ArcMap.Application.FindExtensionByName("ESRI Object Editor");
    if (m_Editor.EditState == ESRI.ArcGIS.Editor.esriEditState.esriStateEditing)
        this.Enabled = true;
        this.Enabled = false;


OnDemand is another word for "just in time". It seems natural that a tool that is in a disabled state at startup should be a just-in-time tool, however that doesn't appear possible. It would be useful if Esri enhanced this so that an Enabled could be set at design time in the xml.


How about something like this:

Protected Overrides Sub OnUpdate()

   Select Case peditor.EditState
    Case ESRI.ArcGIS.Editor.esriEditState.esriStateEditing, ESRI.ArcGIS.Editor.esriEditState.esriStateEditingUnfocused
        Me.Enabled = True
    Case ESRI.ArcGIS.Editor.esriEditState.esriStateNotEditing
        Me.Enabled = False
    Case Else
        Me.Enabled = True
    End Select

  End Sub

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy