Button not being disabled

3649
2
Jump to solution
01-29-2015 08:36 AM
Highlighted
by
New Contributor III

Hi,

I have the proper code in my Add In to disable a button, but it only actually gets disabled after I try to click on it for the first time:

        public AttributeUpdate()

        {

            editorUID.Value = "esriEditor.Editor";

            Global.m_editor = ArcMap.Application.FindExtensionByCLSID(editorUID) as IEditor3;

        }

        protected override void OnUpdate()

        {

            Enabled = Global.m_editor.EditState != esriEditState.esriStateNotEditing;                                

        }

Do I need to do something to for the 'OnUpdate' when the tool first loads??  I thought it would all happen automatically.

When ArcMap first starts the tool is enabled.  Only after clicking on it will the 'OnUpdate' code start kicking in.

Thanks,

0 Kudos
1 Solution

Accepted Solutions
Highlighted
MVP Honored Contributor

In the Config.esriaddinx file where you declare your button, you have to include 'onDemand="False"'. It's documented (although not very clearly) here in the section entitiled "Delay Loading"

This is an example of how it would look in your file

<ArcMap>

      <Commands>

        <Button id="yourID" class=yourClass" message="My Button" caption="Import from Table" tip="Import Scheme from Table" category="My Category" image="Images\ImportScheme_1.png" onDemand="false" />

View solution in original post

0 Kudos
2 Replies
Highlighted
MVP Honored Contributor

In the Config.esriaddinx file where you declare your button, you have to include 'onDemand="False"'. It's documented (although not very clearly) here in the section entitiled "Delay Loading"

This is an example of how it would look in your file

<ArcMap>

      <Commands>

        <Button id="yourID" class=yourClass" message="My Button" caption="Import from Table" tip="Import Scheme from Table" category="My Category" image="Images\ImportScheme_1.png" onDemand="false" />

View solution in original post

0 Kudos
Highlighted
by
New Contributor III

That works perfectly.  Thanks.

Yes, the ESRI documentation is a bit sketchy.  Hard to find things sometimes.

0 Kudos