RadioButton controls

Use RadioButton controls to present mutually exclusive options. When one radio button is selected in a group, the previously selected radio button is deselected, so only one of the options in the group is selected at a time. When a RadioButton control is associated with an attribute field, the value of the selected radio button is written to the associated attribute field.

RadioButton controls are represented by Control objects in the ArcPad object model and by RADIOBUTTON elements in ArcPad Extensible Markup Language (XML).

Attributes

RadioButton control attributes are set at design time in ArcPad Studio on the Control Properties dialog box. They cannot be changed at run time (some attributes have corresponding properties that can be accessed and changed at run time). For more information, see Attributes vs. properties.

Attributes beginning with "on" (for example, onsetfocus) are used to specify the script to run when an event occurs. These attributes are set in the Events page on the Control Properties dialog box. Attributes are written to the customization file (layer definition, applet, default configuration) in ArcPad XML format.

The following table shows the available RadioButton control attributes and descriptions:

Attributes

Descriptions

name

The RadioButton control name. Used to reference the RadioButton control in scripts.

width

The radio button's width.

height

The radio button's height.

x

The x-coordinate of the upper left corner of the radio button.

y

The y-coordinate of the upper left corner of the radio button.

tabstop

Specifies if the TAB key can be used to move the focus to the radio button.

group

Specifies if the radio button starts a new group of controls.

border

Specifies if the radio button has a border.

caption

The caption displayed to the right of the radio button.

required

Specifies if the user must select the radio button.

field

The field of the shapefile's database file format (DBF) table that is linked to the radio button.

readonly

Specifies if the radio button's value can be modified by the user.

value

The value written to the linked field when the radio button is selected.

backgroundcolor

The radio button's background color. If not specified, this value is inherited from the page's backgroundcolor attribute.

color

The radio button's text color. If not specified, this value is inherited from the page's color attribute.

font

The font used for the radio button's text. If not specified, this value is inherited from the page's font attribute.

fontsize

The font size for the radio's button text. If not specified, this value is inherited from the page's fontsize attribute.

fontstyle

The font style for the radio button's text. If not specified, this value is inherited from the page's fontstyle attribute.

onsetfocus

The script to run when an OnSetFocus event occurs.

onkillfocus

The script to run when an OnKillFocus event occurs.

onclick

The script to run when an OnClick event occurs.

onvalidate

The script to run when an OnValidate event occurs.

Events

RadioButton controls generate a range of events as they are operating. You can specify a script to run when any of these events occur in the Events page on the Control Properties dialog box.

The following table shows the available RadioButton control events and descriptions:

Events

Descriptions

OnClick

Occurs when the user clicks the radio button.

OnKillFocus

Occurs when the radio button loses the focus.

OnSetFocus

Occurs when the radio button gets the focus.

OnValidate

Occurs when the radio button is validated.

Properties

RadioButton control properties can be read and set at run time via scripts.

The following table shows the available RadioButton control properties and descriptions:

Properties

Descriptions

Enabled

Returns or sets a value that determines if the radio button is enabled.

Field

Returns a reference to the feature attribute field to which the radio button is bound.

hWnd

Returns the radio button's window handle.

Index

Returns the radio button's index.

Name

Returns the radio button's name.

Parent

Returns a reference to the page containing the radio button.

Text

Returns or sets the text displayed to the right of the radio button.

Type

Returns the control type (for example, RADIOBUTTON for a radio button).

Value

Returns or sets a value that determines if the radio button is selected or unselected.

Visible

Returns or sets a value that determines if the radio button is visible.

Methods

RadioButton control methods can be called at run-time via scripts.

The following table shows the available method and description:

Method

Description

SetFocus

Sets the focus to the radio button.

Referencing a RadioButton control

You can only reference a RadioButton control in a form that is currently displayed. Attempting to reference a RadioButton control in a form that is not currently displayed results in a runtime error. The following discusses the approaches (Direct and Event) to referencing a SymbologyField control.

Direct reference

This involves referencing a RadioButton control via its name, page's name, form's name, and form's parent object. For example, use the following code to reference a RadioButton control with the name "rdoValue1" on a page with the name "pgPage2" in a form with the name "frmSettings" that is present in an applet with the name "Custom Settings":

VBScript

Dim objForm 
Set objForm = Applet.Forms("frmSettings")
Dim objPage
Set objPage = objForm.Pages("pgPage2")
Dim objRadioButton
Set objRadioButton = objPage.Controls("rdoValue1")

JScript

var objForm = Applet.Forms("frmSettings");
var objPage = objForm.Pages("pgPage2");
var objRadioButton = objPage.Controls("rdoValue1");

Python

objForm = Applet.Forms("frmSettings")
objPage = objForm.Pages("pgPage2")
objRadioButton = objPage.Controls("rdoValue1")

Event reference

This involves referencing a RadioButton control in an event handling script. For example, to reference a RadioButton control in its OnClick event handler, you would use the following code:

VBScript

Dim objRadioButton
Set objRadioButton = ThisEvent.Object

JScript

var objRadioButton = ThisEvent.Object;

Python

objRadioButton = ThisEvent.Object

Use the following code to reference a RadioButon control with the name "rdoValue1" on a page with the name "pgPage2" in the OnLoad event handler of its form:

VBScript

Dim objPage
Set objPage = ThisEvent.Object.Pages("pgPage2")
Dim objRadioButton
Set objRadioButton = objPage.Controls("rdoValue1")

JScript

var objPage = ThisEvent.Object.Pages("pgPage2");
var objRadioButton = objPage.Controls("rdoValue1");

Python

ThisEvent.Object.Pages("pgPage2").Controls("rdoValue1")

Initializing a RadioButton control

Radio button initialization involves setting particular radio button properties when the radio button first displays. Generally, the OnLoad event handler of the page or form is the most appropriate place to do this. For example, the following code disables a radio button with the name "rdoValue1" when called in the page's OnLoad event handler:

VBScript

Dim objControls
Set objControls = ThisEvent.Object.Controls 
objControls("rdoValue1").Enabled = False

JScript

var objControls = ThisEvent.Object.Controls;
objControls("rdoValue1").Enabled = false;

Python

ThisEvent.Object.Controls("rdoValue1").Enabled = False

2/7/2013