Label controls
Use a Label control to display text that a user can't directly change. Label controls are represented by Control objects in the ArcPad object model and by LABEL elements in ArcPad Extensible Markup Language (XML).
Attributes
Label 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 are written to the customization file (layer definition, applet, default configuration) in ArcPad XML format.
The following table shows the available Label control attributes and descriptions:
Attributes | Descriptions |
---|---|
name | The name of the Label control. Used to reference the Label control in scripts. |
width | The label's width. |
height | The label's height. |
x | The x-coordinate of the upper left corner of the label. |
y | The y-coordinate of the upper left corner of the label. |
alignment | The alignment of the label's caption. |
caption | The text displayed for the label. |
group | Specifies if the label starts a new group of controls. |
border | Specifies if the label has a border. |
backgroundcolor | The background color to use for the label. If not specified, this value is inherited from the page's backgroundcolor attribute. |
color | The color to use for the label's text. If not specified, this value is inherited from the page's color attribute. |
font | The font for the label. If not specified, this value is inherited from the page's font attribute. |
fontsize | The font size for the label. If not specified, this value is inherited from the page's fontsize attribute. |
fontstyle | The font style for the label. If not specified, this value is inherited from the page's fontstyle attribute. |
Events
Label controls do not generate any events.
Properties
Label control properties can be read and set at run time via scripts.
The following table shows the available Label control properties and descriptions:
Properties | Descriptions |
---|---|
Enabled | Returns or sets a value that determines if the label is enabled. |
hWnd | Returns the label's window handle. |
Index | Returns the label's index. |
Name | Returns the label's name. |
Parent | Returns a reference to the page that contains the label. |
Text | Returns or sets the text that displays for the label. |
Type | Returns the control type (LABEL for a label). |
Value | Returns or sets the text that displays for the label. |
Visible | Returns or sets a value that determines if the label is visible. |
Methods
Label controls do not support any methods.
Referencing a Label control
You can only reference a Label control in a form that is currently displayed. Attempting to reference a Label 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 Label control:
Direct reference
This involves referencing a Label control via its name, page's name, form's name, and form's parent object. For example, use the following code to reference a Label control with the name "lblConfigure" 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 objLabel Set objLabel = objPage.Controls("lblConfigure")
JScript
var objForm = Applet.Forms("frmSettings"); var objPage = objForm.Pages("pgPage2"); var objLabel = objPage.Controls("lblConfigure");
Python
objForm = Applet.Forms("frmSettings") objPage = objForm.Pages("pgPage2") objLabel = objPage.Controls("lblConfigure")
The previous code assumes that it is present in the applet (that is, in the .apa file or its associated script file). If you need to reference the same Label control from a different applet or other customization file, explicitly reference the applet. See the following code:
VBScript
Dim objApplet Set objApplet = Application.Applets("Custom Settings") Dim objForm Set objForm = objApplet.Forms("frmSettings") Dim objPage Set objPage = objForm.Pages("pgPage2") Dim objLabel Set objLabel = objPage.Controls("lblConfigure")
JScript
var objApplet = Application.Applets("Custom Settings"); var objForm = objApplet.Forms("frmSettings"); var objPage = objForm.Pages("pgPage2"); var objLabel = objPage.Controls("lblConfigure");
Python
objApplet = Application.Applets("Custom Settings") objForm = objApplet.Forms("frmSettings") objPage = objForm.Pages("pgPage2") objLabel = objPage.Controls("lblConfigure")
Event reference
This involves referencing a Label control in an event handling script. For example, use the following code to reference a Label control with the name "lblConfigure" 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 objListBox Set objListBox = objPage.Controls("lblConfigure")
JScript
var objPage = ThisEvent.Object.Pages("pgPage2"); var objListBox = objPage.Controls("lblConfigure")
Python
ThisEvent.Object.Pages("pgPage2").Controls("lblConfigure")
Initializing a Label control
Label initialization involves setting particular label properties when the label 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 hides a label with the name "lblConfigure" when called in the page's OnLoad event handler:
VBScript
Dim objControls Set objControls = ThisEvent.Object.Controls objControls("lblConfigure")").Visible = False
JScript
var objControls = ThisEvent.Object.Controls; objControls("lblConfigure").Visible = false;
Python
ThisEvent.Object.Controls("lblConfigure").Visible = False
Specifying the text displayed in a Label control
To set the text displayed in a label at run time, set its Value property to the applicable text string. For example, to display the text "Configure" in a label referenced by the variable objLabel, use the following code:
VBScript
objLabel.Value = "Configure"
JScript
objLabel.Value = "Configure";
Python
objLabel.Value = "Configure"