mlou

Enabled/Disable button in Addin

Discussion created by mlou on Sep 16, 2010
Latest reply on Sep 19, 2010 by mlou
I'm busy converting a lot of my old DLLs into Add-Ins for ArcGIS 10

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:

 
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


This doesn't work in the AddIn.  It looks like what I want should be within
 
Protected Overrides Sub OnUpdate()
Enabled = My.ArcMap.Application IsNot Nothing
End Sub
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.

How can I get my button to Automatically Enable or Disable when certain criteria are met?

Thanks,
Mike.

Outcomes