Click or drag to resize

ListBox Class (Typed)

X#
Create a list box.
Inheritance Hierarchy
Object
  VObject
    Control
      TextControl
        BaseListBox
          ListBox
            ComboBox

Namespace:  XSharp.VO.SDK
Assembly:  XSharp.VOGUIClasses (in XSharp.VOGUIClasses.dll) Version: 2.24 GA
Syntax
 CLASS ListBox INHERIT BaseListBox
Request Example View Source

The ListBox type exposes the following members.

Constructors
  NameDescription
Public methodListBox
Construct a list box.
Top
Properties
  NameDescription
Public propertyCaption
The string representing the caption of the list box.
(Overrides Caption.)
Public propertyCurrentItem
A string representing the displayed list box or combo box item selected.
(Overrides CurrentItem.)
Public propertyCurrentItemNo
A numeric value, between 1 and the ListBox:ItemCount, indicating which item is currently selected.
(Overrides CurrentItemNo.)
Public propertyCurrentText
ListBox:CurrentText is set to the NULL_STRING, since there is no text editing for list boxes.
(Overrides CurrentText.)
Public propertyMultiSelection
Used to identify if the ListBox supports multiple selections.
Public propertySelectedCount
A numeric value representing the total number of items that are currently selected in a multiple selection list box.
Tip Tip
This property is intended for use with a multiple selection list box (i.e., a list box created using the LBOXMULTIPLESEL style).
Public propertySelectedFile
Public propertyTextValue
A string representing the display value (first array's element) for the currently selected item.
(Overrides TextValue.)
Top
Functions
  NameDescription
Public methodAddItem
Add a new item to a list box at a specified position.
(Overrides AddItem(Usual, Usual, Usual).)
Public methodChangeSelected
Change a range of items in a multiple selection list box to a specified selection.
Public methodClear (Overrides Clear.)
Public methodClearSelection
Clear a multiple selection list box of all selections.
Public methodDeleteItem
Remove an item from a list box.
(Overrides DeleteItem(Long).)
Public methodDeselectItem
Turn off the selection of a specified item in a list box.
Public methodEnableItemDrag
Turn the list box into a drag list box.
Public methodCode exampleFillUsing
Specify the set of values to be displayed in the list box, using an array or a data server. These values act as a constraint on the values that may be entered in the list box, and optionally as a translation between program values and display values.
Public methodCode exampleFillUsingBySortedList
Specify the set of values to be displayed in the list box, using an array or a data server. These values act as a constraint on the values that may be entered in the list box, and optionally as a translation between program values and display values.
Public methodFirstSelected
Returns the position of the first item selected in a multiple selection list box, or 0 if no item is selected.
Public methodGetOptimalWidth
Public methodIsSelected
Determine if the list box item at the specified index position is selected.
Public methodListFiles Obsolete.
Fill a list box with the names of all files that match the specified path or file name.
Public methodNextSelected
After calling ListBox:FirstSelected(), this method is used to cycle through the remaining items selected in a multiple selection list box.
Public methodSelectItem
Turn on the selection of an item in a list box.
Public methodSetTabs
Top
Remarks
List boxes and combo boxes display a list of items or choices to the user. The list box methods will allow you to add, arrange, remove, and interrogate the list of items. When one of the items is selected, ListBox:CurrentItem, ListBox:CurrentItemNo, ListBox:TextValue, and ListBox:Value are updated. Either a one-dimensional or two-dimensional array is specified in the FillUsing() method, with a row for each of the items available for selection. With a two-dimensional array, the first element is called the display value, and the second element is called the return value. When an item is selected, ListBox:TextValue contains the first element (the display value), and ListBox:Value contains the second element (the return value). If no item is selected, ListBox:TextValue is NULL_STRING and ListBox:Value is NIL. A list box may be bound to a field (character, date, logical, numeric, or memo) in a server. The field's data value is stored in ListBox:Value. The list box compares the data value to the second element values specified in the FillUsing() array, and if a match is found, the first element (the display value) is stored in ListBox:TextValue. In a "no-match" situation, the list box shows no item selected, ListBox:CurrentItem is NULL_STRING, ListBox:CurrentItemNo is set to 0, and ListBox:TextValue and ListBox:Value reflect the field contents. If an item is selected, ListBox:CurrentItemNo is set to a number between 1 and ListBox:ItemCount, and the corresponding second element is stored as ListBox:Value and as the field's data value.
Tip Tip
All array index references start at 1.
You can also create a multiple selection list box, which allows you to manage multiple items within a list box. Any number of items in a list box can be selected together (referred to as multiple selection). Each item is toggled on/off each time the user clicks on it. A multiple selection list box is created by selecting the LBOXMULTIPLESEL style when creating a ListBox object. Certain properties and methods of this class apply specifically to multiple selection list boxes, including SelectedCount access, ChangeSelected(), ClearSelection(), DeselectItem(), FirstSelected(), NextSelected(), and SelectItem().
Examples
This example creates and fills a list box with a list of animals:
X#
 1CLASS MyWindow INHERIT TopAppWindow
 2HIDDEN oLB AS OBJECT
 3METHOD Init() CLASS MyWindow
 4SUPER:Init()
 5oLB := ListBox{SELF,42,Point{10,10},;
 6Dimension{100,40}}
 7oLB:AddItem("Pig")
 8oLB:AddItem("Cow")
 9oLB:AddItem("Horse")
10oLB:Show()
A X# list box is equivalent to a Windows list box with the LBS_NOTIFY and LBS_SORT styles. List boxes are normally specified in the resource entity like this:
X#
1RESOURCE IDD_ABOUT DIALOG 20, 20, 160, 80
2STYLE WS_POPUP | WS_DLGFRAME
3BEGIN
4LISTBOX IDL_ITEMLIST, 10, 10, 90, 40
5END
See Also