.topic ctrl.listbox
.title ListBox
.toc 1 ListBox
.index ListBox
.index ListIndex
.index ListCount
.index AddItem
.index RemoveItem

.h1 ListBox

VB Equivalent: ListBox -- DVX Widget: listbox

A scrollable list of selectable items. Items are managed via methods (AddItem, RemoveItem, Clear). Supports single and multi-select modes.

.h2 Type-Specific Properties

.table
  Property    Type      Description
  ---------   -------   -------------------------------------------
  ListIndex   Integer   Index of the currently selected item (-1 = no selection).
  ListCount   Integer   Number of items in the list (read-only).
.endtable

.h2 Type-Specific Methods

.table
  Method            Parameters                                Description
  ---------------   ---------------------------------------   -------------------------------------------
  AddItem           Text As String                            Add an item to the end of the list.
  RemoveItem        Index As Integer                          Remove the item at the given index.
  Clear             (none)                                    Remove all items from the list.
  List              Index As Integer                          Return the text of the item at the given index.
  SelectAll         (none)                                    Select all items (multi-select mode).
  ClearSelection    (none)                                    Deselect all items.
  SetMultiSelect    Multi As Boolean                          Enable or disable multi-select mode.
  SetReorderable    Reorderable As Boolean                    Enable or disable drag-to-reorder.
  IsItemSelected    Index As Integer                          Returns True if the item at Index is selected.
  SetItemSelected   Index As Integer, Selected As Boolean     Select or deselect a specific item.
  SetItems          Items As String                           Bulk-load items from a pipe-delimited string (e.g. "Red|Green|Blue").
.endtable

Default Event: Click

.h2 Example

.code
Sub Form_Load ()
    List1.AddItem "Apple"
    List1.AddItem "Banana"
    List1.AddItem "Cherry"
End Sub

Sub List1_Click ()
    Dim idx As Integer
    idx = List1.ListIndex
    If idx >= 0 Then
        Label1.Caption = "Selected: " & List1.List(idx)
    End If
End Sub
.endcode

.link ctrl.common.props Common Properties, Events, and Methods
.link ctrl.combobox ComboBox
.link ctrl.dropdown DropDown
