Called when this button is clicked.

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 void OnClick()
Visual Basic (Declaration)
Protected Overridable Sub OnClick
Visual C++
protected:
virtual void OnClick()

Remarks

When inheriting Button class to create a custom button, write the code that performs the action when the button is clicked in the OnClick method.

Examples

The example code below shows a very simple button class that shows a dockable window.
CopyC#
public ToggleDockWndBtn() 
{
  this.Checked = true;
}

protected override void OnClick()
{
  //Get dockable window.
  UID dockWinID = new UIDClass();
  dockWinID.Value = @"esriArcMapUI.TOCDockableWindow";
  IDockableWindow dockWindow = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID);
  dockWindow.Show(!dockWindow.IsVisible());
}

protected override void OnUpdate()
{
  this.Enabled = m_mainExtension.IsExtensionEnabled;
}
CopyVB.NET
Public Sub New()
  Me.Checked = True
End Sub

Protected Overloads Overrides Sub OnClick()
  'Get dockable window. 
  Dim dockWinID As UID = New UIDClass()
  dockWinID.Value = "esriArcMapUI.TOCDockableWindow"
  Dim dockWindow As IDockableWindow = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID)
  dockWindow.Show(Not dockWindow.IsVisible())
End Sub

Protected Overloads Overrides Sub OnUpdate()
  Me.Enabled = m_mainExtension.IsExtensionEnabled
End Sub

See Also