ArcGIS Explorer Component Help |
CheckBox..::.OnClick Method |
CheckBox Class Example See Also |
Called when the checkbox is clicked.
Namespace:
ESRI.ArcGISExplorer.ApplicationAssembly: ESRI.ArcGISExplorer.Application (in ESRI.ArcGISExplorer.Application.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public virtual void OnClick() |
Visual Basic (Declaration) |
---|
Public Overridable Sub OnClick |
Remarks
Override the OnClick method to run code when the user clicks the checkbox on the Ribbon. The majority of code in a custom CheckBox is generally found in this method.
Examples
The example code below shows a very simple CheckBox class which shows toggles the basemap in current display on and off when user clicks the
CheckBox.
CopyC#
using System; using System.Text; using ESRI.ArcGISExplorer.Application; using ESRI.ArcGISExplorer.Mapping; namespace NewCheckBox { public class NewCheckBox : ESRI.ArcGISExplorer.Application.CheckBox { Basemap lastBasemap = null; MapDisplay disp = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay; public NewCheckBox() { // Set up initial state of the checkbox if (disp.Map.Basemap == null) { this.Checked = false; } else { this.Checked = true; } } public override void OnClick() { // Toggle the basemap on or off if (this.Checked) { if (lastBasemap != null) { disp.Map.Basemap = lastBasemap; } } else { // Unchecking clears basemap - store it for replacing it later. if (disp.Map.Basemap != null) { lastBasemap = disp.Map.Basemap; disp.Map.Basemap = null; } } } } }
CopyVB.NET
Imports System.Text Imports ESRI.ArcGISExplorer.Application Imports ESRI.ArcGISExplorer.Mapping Namespace NewCheckBox Public Class NewCheckBox Inherits ESRI.ArcGISExplorer.Application.CheckBox Private lastBasemap As Basemap = Nothing Private disp As MapDisplay = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay Public Sub New() ' Set up initial state of the checkbox If disp.Map.Basemap Is Nothing Then Me.Checked = False Else Me.Checked = True End If End Sub Public Overrides Sub OnClick() ' Toggle the basemap on or off If Me.Checked Then If lastBasemap IsNot Nothing Then disp.Map.Basemap = lastBasemap End If Else ' Unchecking clears basemap - store it for replacing it later. If disp.Map.Basemap IsNot Nothing Then lastBasemap = disp.Map.Basemap disp.Map.Basemap = Nothing End If End If End Sub End Class End Namespace