Called when the extension is being loaded by the framework, and when toggling the extension state in the Extension dialog.

Namespace:  ESRI.ArcGIS.Desktop.AddIns

Assembly:  ESRI.ArcGIS.Desktop.Addins (in ESRI.ArcGIS.Desktop.Addins.dll) Version: 10.0.0.0 (10.0.0.0)

Syntax

C#
protected virtual bool OnSetState(
	ExtensionState state
)
Visual Basic (Declaration)
Protected Overridable Function OnSetState ( _
	state As ExtensionState _
) As Boolean
Visual C++
protected:
virtual bool OnSetState(
	ExtensionState state
)

Parameters

state
Type: ESRI.ArcGIS.Desktop.AddIns..::.ExtensionState

The state.

Return Value

If returns false, the extension is being locked and can't be activated or de-activated.

Remarks

Override this method to set the extension's availability state.

Examples

The code below shows an extension class that sets and gets its state.
CopyC#
protected override bool OnSetState(ExtensionState state)
{
  //Users can optionally check license here.
  this.State = state;
  return true;
}

protected override ExtensionState OnGetState()
{
  return this.State;
}

internal bool IsExtensionEnabled
{
  get
  {
    return this.State == ExtensionState.Enabled;
  }
}
CopyVB.NET
Protected Overloads Overrides Function OnSetState(ByVal state As ExtensionState) As Boolean
  'Users can optionally check license here. 
  Me.State = state
  Return True
End Function

Protected Overloads Overrides Function OnGetState() As ExtensionState
  Return Me.State
End Function

Friend ReadOnly Property IsExtensionEnabled() As Boolean
  Get
    Return Me.State = ExtensionState.Enabled
  End Get
End Property

See Also