<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Enabled/Disable button in Addin in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/enabled-disable-button-in-addin/m-p/736716#M19574</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm busy converting a lot of my old DLLs into Add-Ins for ArcGIS 10&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My old toolbars had some buttons that would be enabled or disabled based on whether certain things were found in the map or not, something along the lines of:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; 
Public Overrides ReadOnly Property Enabled() As Boolean
Get
 
If pMxDocument.FocusMap.LayerCount = 0 Then
Return MyBase.Enabled = False
Else
Return MyBase.Enabled = True
End If
 
End Get
End Property
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This doesn't work in the AddIn.&amp;nbsp; It looks like what I want should be within &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; 
Protected Overrides Sub OnUpdate()
Enabled = My.ArcMap.Application IsNot Nothing
End Sub
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;SPAN&gt;However it doesn't seem to automatically pick up when things change - I actually have to click on my button to have it Enable or Disable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I get my button to Automatically Enable or Disable when certain criteria are met?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 Sep 2010 01:47:13 GMT</pubDate>
    <dc:creator>MikeLouwrens</dc:creator>
    <dc:date>2010-09-17T01:47:13Z</dc:date>
    <item>
      <title>Enabled/Disable button in Addin</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/enabled-disable-button-in-addin/m-p/736716#M19574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm busy converting a lot of my old DLLs into Add-Ins for ArcGIS 10&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My old toolbars had some buttons that would be enabled or disabled based on whether certain things were found in the map or not, something along the lines of:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; 
Public Overrides ReadOnly Property Enabled() As Boolean
Get
 
If pMxDocument.FocusMap.LayerCount = 0 Then
Return MyBase.Enabled = False
Else
Return MyBase.Enabled = True
End If
 
End Get
End Property
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This doesn't work in the AddIn.&amp;nbsp; It looks like what I want should be within &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; 
Protected Overrides Sub OnUpdate()
Enabled = My.ArcMap.Application IsNot Nothing
End Sub
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;SPAN&gt;However it doesn't seem to automatically pick up when things change - I actually have to click on my button to have it Enable or Disable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I get my button to Automatically Enable or Disable when certain criteria are met?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Sep 2010 01:47:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/enabled-disable-button-in-addin/m-p/736716#M19574</guid>
      <dc:creator>MikeLouwrens</dc:creator>
      <dc:date>2010-09-17T01:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Enabled/Disable button in Addin</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/enabled-disable-button-in-addin/m-p/736717#M19575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The only way that I've been able to make this work without having to click on them first is to set onDemand to False in the config file. I would love to know if someone else has a better way.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Sep 2010 13:21:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/enabled-disable-button-in-addin/m-p/736717#M19575</guid>
      <dc:creator>ScottDavis</dc:creator>
      <dc:date>2010-09-17T13:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: Enabled/Disable button in Addin</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/enabled-disable-button-in-addin/m-p/736718#M19576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was just about to post the same question - thanks for the OnDemand hint, it works great.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Brian&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Sep 2010 14:11:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/enabled-disable-button-in-addin/m-p/736718#M19576</guid>
      <dc:creator>BrianBottoms</dc:creator>
      <dc:date>2010-09-17T14:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: Enabled/Disable button in Addin</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/enabled-disable-button-in-addin/m-p/736719#M19577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The only way that I've been able to make this work without having to click on them first is to set onDemand to False in the config file. I would love to know if someone else has a better way.&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;It appears that the onDemand attribute is the way we're supposed to control it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Indicates if it is a delay loading command. By default, the assemblies associated with Add-In buttons and tools are not loaded until the corresponding item on a toolbar or menu is clicked by the user. This behavior helps conserve application memory and other resources. Since the enabled state of an Add-In button or tool is controlled by the OnUpdate method within code, they will initially appear enabled. If you need tighter control over the initial enabled state of a button or tool, you will need to override the default behavior and force the item to load at startup by setting the attribute equal to false. &lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;(from &lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/001v/001v0000024p000000.htm"&gt;&lt;SPAN style="color: #0000ff; font-size: 2; text-decoration: underline;"&gt;http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/001v/001v0000024p000000.htm&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Sep 2010 20:57:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/enabled-disable-button-in-addin/m-p/736719#M19577</guid>
      <dc:creator>MikeLouwrens</dc:creator>
      <dc:date>2010-09-19T20:57:24Z</dc:date>
    </item>
  </channel>
</rss>

