Enable / disable a button when start / stop an editing session

342
2
09-12-2011 10:43 AM
ducksunlimited
New Contributor
HI All,

Hope I can get some help here.

I have an ArcGIS 10 add-in (IDE VB.NET Express 2008) with a button. I want this button to be enabled only when an editing session is started. Here is what I got. Also I added the onDemand = "Flase" property for the button. Any help would be appreciated.

Protected Overrides Sub OnUpdate()
        Dim application As ESRI.ArcGIS.Framework.IApplication = Nothing

        Dim pID As New UIDClass()
        pID.Value = "esriEditor.Editor"

        Dim pEditor As IEditor
        pEditor = application.FindExtensionByCLSID(pID)

        If pEditor.EditState = 1 Then
            Me.Enabled = True
        End If
    End Sub

Russel
0 Kudos
2 Replies
by Anonymous User
Not applicable
In its simplest form the update stub will look like this:

'VB
  Protected Overrides Sub OnUpdate()
    Enabled = (_editor.EditState = esriEditState.esriStateEditing)
  End Sub


This assumes you have set _editor in the constructor.
The onDemand tag should also be false as you have stated.
0 Kudos
ducksunlimited
New Contributor
Worked - Thank you!


In its simplest form the update stub will look like this:

'VB
  Protected Overrides Sub OnUpdate()
    Enabled = (_editor.EditState = esriEditState.esriStateEditing)
  End Sub


This assumes you have set _editor in the constructor.
The onDemand tag should also be false as you have stated.
0 Kudos