ListBox control

A ListBox displays available options or values. If more options or values exist than can display in the ListBox at one time or the text exceeds the width of the ListBox, the ListBox will have one or two (vertical or horizontal) scroll bars.

Properties

ListBox property

Datatype

Description

Accelerator

Integer

Specifies the ASCII value of the key you want to assign as the accelerator key for a control.

AccessibleDescription

String

A description of the control and/or its purpose for use by accessibility tools such as readers for visually impaired users.

AccessibleName

String

A label that briefly describes the control, such as the text in a button or the name of a menu item.

AccessibleRole

AccessibleRole (enumerated)

Describes what kind of user interface element the control is.

BackColor

Long

Specifies the numeric value of the background color: -2 to 16,777,215. For more information about color, see the RGB function in the PowerScript Reference.

Border

Boolean

Specifies whether the control has a border. Values are:

  • TRUE – Control has a border.

  • FALSE – Control does not have a border.

BorderStyle

BorderStyle (enumerated)

Specifies the style of the border of the control. Values are:

  • StyleBox!

  • StyleLowered!

  • StyleRaised!

  • StyleShadowBox!

BringToTop

Boolean

Specifies whether PowerBuilder moves the control to the top of the front-to-back order. Values are:

  • TRUE – Control moved to top.

  • FALSE – Control not moved to top.

ClassDefinition

PowerObject

An object of type PowerObject containing information about the class definition of the object or control.

DisableNoScroll

Boolean

Specifies behavior of a scroll bar. Values are:

  • TRUE – The scroll bar will always be visible but will be disabled when all the items can be accessed without it.

  • FALSE – The scroll bar will be displayed only if it is necessary (based on the number of items and the height of the list box).

DragAuto

Boolean

Specifies whether PowerBuilder puts the control automatically into Drag mode. Values are:

  • TRUE – When the control is clicked, the control is automatically in Drag mode.

  • FALSE – When the control is clicked, the control is not automatically in Drag mode. You have to manually put the control into Drag mode by using the Drag function.

DragIcon

String

Specifies the name of the stock icon or the file containing the icon you want to display when the user drags the control (the ICO file). The default icon is a box the size of the control.

When the user drags the control, the icon displays when the control is over an area in which the control can be dropped (a valid drop area). When the control is over an area that is not a valid drop area, the No-Drop icon displays.

Enabled

Boolean

Specifies whether the control is enabled (can be selected). Values are:

  • TRUE – Control can be selected.

  • FALSE – Control cannot be selected.

ExtendedSelect

Boolean

Specifies whether users can select multiple items in the listbox at one time. Values are:

  • TRUE – Users can select multiple items by clicking on an item and dragging the mouse up or down to select items; using Click or Shift+ Click to select a sequential group of items; or using Ctrl+ Click on multiple items.

  • FALSE – Users cannot select multiple items.

Used with MultiSelect The MultiSelect property allows users to select multiple items in a list box by simply clicking on the items. If MultiSelect = true and ExtendedSelect = true, then the behavior of ExtendedSelect takes precedence.

FaceName

String

Specifies the name of the typeface in which the text of the control displays (for example, ARIAL or COURIER).

FontCharSet

FontCharSet (enumerated)

Specifies the font character set used for the text in the control. For a complete list of possible values, see the list of properties for the FontCharSet variable on the Enumerated tab page of the Browser.

FontFamily

FontFamily (enumerated)

Specifies the font family (type style) used for the text in the control. Values are:

  • AnyFont!

  • Decorative!

  • Modern!

  • Roman!

  • Script!

  • Swiss!

FontPitch

FontPitch (enumerated)

Specifies the pitch (spacing) of the font used for the text in the control. Values are:

  • Default!

  • Fixed!

  • Variable!

Height

Integer

Specifies the height of the control, in PowerBuilder units.

HScrollBar

Boolean

Specifies whether a horizontal scroll bar displays. Values are:

  • TRUE – Horizontal scroll bar displays.

  • FALSE – Horizontal scroll bar does not display.

Italic

Boolean

Specifies whether the text in the control is italic. Values are:

  • TRUE – Text is italic.

  • FALSE – Text is not italic.

Item[ ]

String

Specifies the items in the control.

MultiSelect

Boolean

Specifies whether users can select multiple items in the ListBox at one time. Values are:

  • TRUE – Users can select multiple items.

  • FALSE – Users cannot select multiple items.

    Used with ExtendedSelect The MultiSelect property allows users to select multiple items in a list box by simply clicking on the items. If MultiSelect = true and ExtendedSelect = true, then the behavior of ExtendedSelect takes precedence.

Pointer

String

Specifies the name of the stock pointer or the file containing the pointer used for the control.

RightToLeft

Boolean

Specifies that characters should be displayed in right-to-left order. The application must be running on an operating system that supports right-to-left display. Values are:

  • TRUE – Characters display in right-to-left order.

  • FALSE – Characters display in left-to-right order.

Sorted

Boolean

Specifies whether the items in the ListBox are sorted. Values are:

  • TRUE – Items are sorted.

  • FALSE – Items are not sorted.

TabOrder

Integer

Specifies the tab value of the control (0 means the user cannot tab to the control).

TabStop[ ]

Integer array

Specifies the positions of the tab stops in the ListBox. The tab stops are in character positions, and the tab stop delimiter is a space. If you assign a value to only the first tab stop, TabStop[1], the tab stops are equally spaced using the number of character positions specified for the first tab stop. If more than one tab stop is entered, tab stops are located in the positions specified. You can define 16 tab stops in the control; the default array is TabStop[8], with a tab stop every eight character positions.

Tag

String

Specifies the tag value assigned to the control.

TextColor

Long

Specifies the numeric value of the color used for text: -2 to 16,777,215. For more information about color, see the RGB function in the PowerScript Reference.

TextSize

Integer

Specifies the size of the text in the control, in points. For backward compatibility, the size is stored as a negative number; for example, 10-point text size is stored as -10.

Underline

Boolean

Specifies whether the text in the control is underlined. Values are:

  • TRUE – Text is underlined.

  • FALSE – Text is not underlined.

Visible

Boolean

Specifies whether the control is visible. Values are:

  • TRUE – Control is visible.

  • FALSE – Control is not visible.

VScrollBar

Boolean

Specifies whether a vertical scroll bar is displayed on the right of the ListBox. Values are:

  • TRUE – Vertical scroll bar is displayed.

  • FALSE – Vertical scroll bar is not displayed.

Weight

Integer

Specifies the stroke weight of the text in the control; for example, 400 for normal or 700 for bold.

Width

Integer

Specifies the width of the control, in PowerBuilder units.

X

Integer

Specifies the X position (the distance from the left edge of the window), in PowerBuilder units.

Y

Integer

Specifies the Y position (the distance from the top of the window), in PowerBuilder units.

Events

ListBox event

Occurs

Constructor

Immediately before the Open event occurs in the window.

Destructor

Immediately after the Close event occurs in the window.

DoubleClicked

When the control is double-clicked (selected and activated).

DragDrop

When a dragged control is dropped on the control.

DragEnter

When a dragged control enters the control.

DragLeave

When a dragged control leaves the control.

DragWithin

When a dragged control is within the control.

GetFocus

Just before the control receives focus (before it is selected and becomes active).

Help

When the user presses the F1 key or drags the context help button (question mark) from the title bar to a menu item or control.

LoseFocus

When the control loses focus (becomes inactive).

Other

When a Controls message occurs that is not a PowerBuilder event.

RButtonDown

When the right mouse button is pressed on the control.

SelectionChanged

When an item in the control is selected.

Functions

ListBox function

Datatype returned

Description

AddItem

Integer

Adds a new item to the end of the ListBox. If the Sorted property of the control is true, the items are sorted again after the item is added.

The AddItem function does not update the Item[ ] property of this control.

ClassName

String

Returns the name assigned to the control.

DeleteItem

Integer

Deletes the item indicated by the index from the ListBox.

DirList

Boolean

Populates the ListBox with a list of the files of the specified type that match the specified file pattern.

DirSelect

Boolean

Returns the current selection for the control and puts it in the specified variable.

Drag

Integer

Starts or ends the dragging of a control.

FindItem

Integer

Finds the first item in the ListBox (after the specified index) that begins with the specified string.

GetContextService

Integer

Creates a reference to a context-specific instance of the specified service.

GetParent

PowerObject

Returns a reference to the name of the parent object.

Hide

Integer

Makes the control invisible.

InsertItem

Integer

Adds a new item to the ListBox before the item indicated by the index. If the Sorted property of the control is true, the items are sorted again after the item is added.

Move

Integer

Moves the control to a specified location.

PointerX

Integer

Returns the distance the pointer is from the left edge of the control.

PointerY

Integer

Returns the distance the pointer is from the top of the control.

PostEvent

Boolean

Adds an event to the end of the message queue for the control.

Print

Integer

Prints the control.

Reset

Integer

Removes all items from the control.

Resize

Integer

Changes the size of the control.

SelectedIndex

Integer

Returns the index of the item in the ListBox that is currently selected. If more than one item is selected, it returns the index of the first selected item.

SelectedItem

String

Returns the text of the first selected item.

SelectItem

Integer

Finds and highlights an item in the control. Use Syntax 1 when you know the text of the item but not its position. Use Syntax 2 when you know the position of the item in the control’s list or you want to clear the current selection.

SelectItem has no effect on a ListBox whose MultiSelect property is true. Instead, use SetState to select items without affecting the selected state of other items in the list.

SetFocus

Integer

Sets focus to the control.

SetPosition

Integer

Specifies the position of the control in the front-to-back order of the window.

SetRedraw

Integer

Controls automatic redrawing of the control after each change in its properties.

SetState

Integer

Sets the state (highlighted or not highlighted) of the item indicated by the specified index. SetState works only for multiselect controls (those for which the MultiSelect property is true).

SetTop

Integer

Scrolls the items in the control so that the item indicated by the specified index is at the top of the control.

Show

Integer

Makes the control visible.

State

Integer

Returns 1 if the item specified by the specified index is selected (highlighted) and 0 if the item is not selected.

Text

String

Returns the text of the item in the control identified by the specified index.

Top

Integer

Returns the index number of the item currently at the top of the control.

TotalItems

Integer

Returns the total number of items in the control.

TotalSelected

Integer

Returns the total number of items selected in the control.

TriggerEvent

Integer

Triggers a specified event in the control and executes the script for the event.

TypeOf

Object

Returns the type of the control.