Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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.

share|improve this answer

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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.