<div class="meta" robots="noindex">

</div>

Class

# ListBox (deprecated)

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2021r3. Please use `DesktopListBox</api/user_interface/desktop/desktoplistbox>` as a replacement.

</div>

## Description

The scrollable <span class="title-ref">ListBox</span> control is used to display one or more columns of information.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                         | Type                                                   | Read-Only | Shared |
|--------------------------------------------------------------|--------------------------------------------------------|-----------|--------|
| `Active<listbox.active>`                                     | `Boolean</api/data_types/boolean>`                     | ✓         |        |
| `ActiveTextControl<listbox.activetextcontrol>`               | `TextEdit</api/deprecated/textedit>`                   | ✓         |        |
| `AllowAutoDeactivate<listbox.allowautodeactivate>`           | `Boolean</api/data_types/boolean>`                     |           |        |
| `AllowAutoHideScrollbars<listbox.allowautohidescrollbars>`   | `Boolean</api/data_types/boolean>`                     |           |        |
| `AllowExpandableRows<listbox.allowexpandablerows>`           | `Boolean</api/data_types/boolean>`                     |           |        |
| `AllowFocusRing<listbox.allowfocusring>`                     | `Boolean</api/data_types/boolean>`                     |           |        |
| `AllowResizableColumns<listbox.allowresizablecolumns>`       | `Boolean</api/data_types/boolean>`                     | ✓         |        |
| `AllowRowDragging<listbox.allowrowdragging>`                 | `Boolean</api/data_types/boolean>`                     |           |        |
| `AllowRowReordering<listbox.allowrowreordering>`             | `Boolean</api/data_types/boolean>`                     |           |        |
| `AllowTabStop<listbox.allowtabstop>`                         | `Boolean</api/data_types/boolean>`                     |           |        |
| `Bold<listbox.bold>`                                         | `Boolean</api/data_types/boolean>`                     |           |        |
| `CellAlignmentAt<listbox.cellalignmentat>`                   | `Integer</api/data_types/integer>`                     |           |        |
| `CellAlignmentOffsetAt<listbox.cellalignmentoffsetat>`       | `Integer</api/data_types/integer>`                     |           |        |
| `CellBorderBottomAt<listbox.cellborderbottomat>`             | `Integer</api/data_types/integer>`                     |           |        |
| `CellBorderLeftAt<listbox.cellborderleftat>`                 | `Integer</api/data_types/integer>`                     |           |        |
| `CellBorderRightAt<listbox.cellborderrightat>`               | `Integer</api/data_types/integer>`                     |           |        |
| `CellBorderTopAt<listbox.cellbordertopat>`                   | `Integer</api/data_types/integer>`                     |           |        |
| `CellCheckBoxValueAt<listbox.cellcheckboxvalueat>`           | `Boolean</api/data_types/boolean>`                     |           |        |
| `CellTypeAt<listbox.celltypeat>`                             | `Integer</api/data_types/integer>`                     |           |        |
| `ColumnAlignmentAt<listbox.columnalignmentat>`               | `Integer</api/data_types/integer>`                     |           |        |
| `ColumnAlignmentOffsetAt<listbox.columnalignmentoffsetat>`   | `Integer</api/data_types/integer>`                     |           |        |
| `ColumnAt<listbox.columnat>`                                 | `ListColumn</api/deprecated/listcolumn>`               |           |        |
| `ColumnCount<listbox.columncount>`                           | `Integer</api/data_types/integer>`                     |           |        |
| `ColumnSortDirectionAt<listbox.columnsortdirectionat>`       | `Integer</api/data_types/integer>`                     |           |        |
| `ColumnTypeAt<listbox.columntypeat>`                         | `Integer</api/data_types/integer>`                     |           |        |
| `ColumnWidths<listbox.columnwidths>`                         | `String</api/data_types/string>`                       |           |        |
| `DefaultRowHeight<listbox.defaultrowheight>`                 | `Integer</api/data_types/integer>`                     |           |        |
| `DropIndicatorVisible<listbox.dropindicatorvisible>`         | `Boolean</api/data_types/boolean>`                     |           |        |
| `Enabled<listbox.enabled>`                                   | `Boolean</api/data_types/boolean>`                     |           |        |
| `FontName<listbox.fontname>`                                 | `String</api/data_types/string>`                       |           |        |
| `FontSize<listbox.fontsize>`                                 | `Single</api/data_types/single>`                       |           |        |
| `FontUnit<listbox.fontunit>`                                 | `FontUnits</api/graphics/fontunits>`                   |           |        |
| `GridLinesHorizontalStyle<listbox.gridlineshorizontalstyle>` | `Integer</api/data_types/integer>`                     |           |        |
| `GridLinesVerticalStyle<listbox.gridlinesverticalstyle>`     | `Integer</api/data_types/integer>`                     |           |        |
| `Handle<listbox.handle>`                                     | `Integer</api/data_types/integer>`                     | ✓         |        |
| `HasBorder<listbox.hasborder>`                               | `Boolean</api/data_types/boolean>`                     |           |        |
| `HasHeader<listbox.hasheader>`                               | `Boolean</api/data_types/boolean>`                     |           |        |
| `HasHorizontalScrollbar<listbox.hashorizontalscrollbar>`     | `Boolean</api/data_types/boolean>`                     |           |        |
| `HasVerticalScrollbar<listbox.hasverticalscrollbar>`         | `Boolean</api/data_types/boolean>`                     |           |        |
| `HeaderHeight<listbox.headerheight>`                         | `Integer</api/data_types/integer>`                     |           |        |
| `HeadingIndex<listbox.headingindex>`                         | `Integer</api/data_types/integer>`                     |           |        |
| `Height<listbox.height>`                                     | `Integer</api/data_types/integer>`                     |           |        |
| `Index<listbox.index>`                                       | `Integer</api/data_types/integer>`                     | ✓         |        |
| `InitialValue<listbox.initialvalue>`                         | `String</api/data_types/string>`                       |           |        |
| `Italic<listbox.italic>`                                     | `Boolean</api/data_types/boolean>`                     |           |        |
| `LastAddedRowIndex<listbox.lastaddedrowindex>`               | `Integer</api/data_types/integer>`                     | ✓         |        |
| `LastColumnIndex<listbox.lastcolumnindex>`                   | `Integer</api/data_types/integer>`                     | ✓         |        |
| `LastRowIndex<listbox.lastrowindex>`                         | `Integer</api/data_types/integer>`                     | ✓         |        |
| `Left<listbox.left>`                                         | `Integer</api/data_types/integer>`                     |           |        |
| `List<listbox.list>`                                         | `String</api/data_types/string>`                       |           |        |
| `LockBottom<listbox.lockbottom>`                             | `Boolean</api/data_types/boolean>`                     |           |        |
| `LockLeft<listbox.lockleft>`                                 | `Boolean</api/data_types/boolean>`                     |           |        |
| `LockRight<listbox.lockright>`                               | `Boolean</api/data_types/boolean>`                     |           |        |
| `LockTop<listbox.locktop>`                                   | `Boolean</api/data_types/boolean>`                     |           |        |
| `MouseCursor<listbox.mousecursor>`                           | `MouseCursor</api/user_interface/desktop/mousecursor>` |           |        |
| `MouseX<listbox.mousex>`                                     | `Integer</api/data_types/integer>`                     | ✓         |        |
| `MouseY<listbox.mousey>`                                     | `Integer</api/data_types/integer>`                     | ✓         |        |
| `Name<listbox.name>`                                         | `String</api/data_types/string>`                       | ✓         |        |
| `PanelIndex<listbox.panelindex>`                             | `Integer</api/data_types/integer>`                     |           |        |
| `Parent<listbox.parent>`                                     | `Control</api/deprecated/control>`                     |           |        |
| `RequiresSelection<listbox.requiresselection>`               | `Boolean</api/data_types/boolean>`                     |           |        |
| `RowCount<listbox.rowcount>`                                 | `Integer</api/data_types/integer>`                     | ✓         |        |
| `RowHeight<listbox.rowheight>`                               | `Integer</api/data_types/integer>`                     | ✓         |        |
| `RowSelectionType<listbox.rowselectiontype>`                 | `Integer</api/data_types/integer>`                     |           |        |
| `Scope<listbox.scope>`                                       | `Integer</api/data_types/integer>`                     | ✓         |        |
| `ScrollPosition<listbox.scrollposition>`                     | `Integer</api/data_types/integer>`                     |           |        |
| `ScrollPositionX<listbox.scrollpositionx>`                   | `Integer</api/data_types/integer>`                     |           |        |
| `Selected<listbox.selected>`                                 | `Boolean</api/data_types/boolean>`                     |           |        |
| `SelectedRowCount<listbox.selectedrowcount>`                 | `Integer</api/data_types/integer>`                     | ✓         |        |
| `SelectedRowIndex<listbox.selectedrowindex>`                 | `Integer</api/data_types/integer>`                     |           |        |
| `SelectedRowValue<listbox.selectedrowvalue>`                 | `String</api/data_types/string>`                       |           |        |
| `SortingColumn<listbox.sortingcolumn>`                       | `Integer</api/data_types/integer>`                     |           |        |
| `TabIndex<listbox.tabindex>`                                 | `Integer</api/data_types/integer>`                     |           |        |
| `Tooltip<listbox.tooltip>`                                   | `String</api/data_types/string>`                       |           |        |
| `Top<listbox.top>`                                           | `Integer</api/data_types/integer>`                     |           |        |
| `Transparent<listbox.transparent>`                           | `Boolean</api/data_types/boolean>`                     |           |        |
| `TrueWindow<listbox.truewindow>`                             | `Window</api/deprecated/window>`                       | ✓         |        |
| `Underline<listbox.underline>`                               | `Boolean</api/data_types/boolean>`                     |           |        |
| `Visible<listbox.visible>`                                   | `Boolean</api/data_types/boolean>`                     |           |        |
| `Width<listbox.width>`                                       | `Integer</api/data_types/integer>`                     |           |        |
| `Window<listbox.window>`                                     | `Window</api/deprecated/window>`                       | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                               | Parameters                                                                                                                                  | Returns                                  | Shared |
|----------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------|--------|
| `AcceptFileDrop<listbox.acceptfiledrop>`           | FileType As `String</api/data_types/string>`                                                                                                |                                          |        |
| `AcceptPictureDrop<listbox.acceptpicturedrop>`     |                                                                                                                                             |                                          |        |
| `AcceptRawDataDrop<listbox.acceptrawdatadrop>`     | Type As `String</api/data_types/string>`                                                                                                    |                                          |        |
| `AcceptTextDrop<listbox.accepttextdrop>`           |                                                                                                                                             |                                          |        |
| `AddAllRows<listbox.addallrows>`                   | items() As `String</api/data_types/string>`                                                                                                 |                                          |        |
| `AddExpandableRow<listbox.addexpandablerow>`       | text As `String</api/data_types/string>`                                                                                                    |                                          |        |
| `AddExpandableRowAt<listbox.addexpandablerowat>`   | index As `Integer</api/data_types/integer>`, text As `String</api/data_types/string>`                                                       |                                          |        |
| `AddRow<listbox.addrow>`                           | `ParamArray</api/language/paramarray>` Item As `String</api/data_types/string>`                                                             |                                          |        |
| `AddRowAt<listbox.addrowat>`                       | RowNumber As `Integer</api/data_types/integer>`, Item As `String</api/data_types/string>`, \[Indent As `Integer</api/data_types/integer>`\] |                                          |        |
| `CellBold<listbox.cellbold>`                       | RowNumber As `Integer</api/data_types/integer>`, ColumnNumber As `Integer</api/data_types/integer>`                                         | `Boolean</api/data_types/boolean>`       |        |
| `CellCheckBoxStateAt<listbox.cellcheckboxstateat>` | Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`                                                     | `CheckBox<checkbox.visualstates>`        |        |
| `CellItalic<listbox.cellitalic>`                   | RowNumber As `Integer</api/data_types/integer>`, ColumnNumber As `Integer</api/data_types/integer>`                                         | `Boolean</api/data_types/boolean>`       |        |
| `CellTagAt<listbox.celltagat>`                     | Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`                                                     | `Variant</api/data_types/variant>`       |        |
| `CellToolTipAt<listbox.celltooltipat>`             | RowNumber As `Integer</api/data_types/integer>`, ColumnNumber As `Integer</api/data_types/integer>`                                         | `String</api/data_types/string>`         |        |
| `CellUnderline<listbox.cellunderline>`             | RowNumber As `Integer</api/data_types/integer>`, ColumnNumber As `Integer</api/data_types/integer>`                                         | `Boolean</api/data_types/boolean>`       |        |
| `CellValueAt<listbox.cellvalueat>`                 |                                                                                                                                             |                                          |        |
| `Close<listbox.close_method>`                      |                                                                                                                                             |                                          |        |
| `ColumnFromXY<listbox.columnfromxy>`               | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                            | `Integer</api/data_types/integer>`       |        |
| `ColumnSortTypeAt<listbox.columnsorttypeat>`       | Column As `Integer</api/data_types/integer>`                                                                                                | `ListBox<listbox.sorttypes>`             |        |
| `ColumnTagAt<listbox.columntagat>`                 | Column As `Integer</api/data_types/integer>`                                                                                                | `Variant</api/data_types/variant>`       |        |
| `DrawInto<listbox.drawinto>`                       | g As `Graphics</api/graphics/graphics>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`                   |                                          |        |
| `EditCellAt<listbox.editcellat>`                   | Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`                                                     |                                          |        |
| `ExpandableRowAt<listbox.expandablerowat>`         | row As `Integer</api/data_types/integer>`                                                                                                   | `Boolean</api/data_types/boolean>`       |        |
| `HeaderAt<listbox.headerat>`                       |                                                                                                                                             | `String</api/data_types/string>`         |        |
| `Invalidate<listbox.invalidate>`                   | \[EraseBackground As `Boolean</api/data_types/boolean>`\]                                                                                   |                                          |        |
| `InvalidateCell<listbox.invalidatecell>`           | Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`                                                     |                                          |        |
| `PressHeader<listbox.pressheader>`                 | Column As `Integer</api/data_types/integer>`                                                                                                |                                          |        |
| `Refresh<listbox.refresh>`                         | eraseBackground As `Boolean</api/data_types/boolean>`                                                                                       |                                          |        |
| `RemoveAllRows<listbox.removeallrows>`             |                                                                                                                                             |                                          |        |
| `RemoveRowAt<listbox.removerowat>`                 | RowNumber As `Integer</api/data_types/integer>`                                                                                             |                                          |        |
| `RowDepthAt<listbox.rowdepthat>`                   | row As `Integer</api/data_types/integer>`                                                                                                   | `Integer</api/data_types/integer>`       |        |
| `RowExpandedAt<listbox.rowexpandedat>`             | RowNumber As `Integer</api/data_types/integer>`                                                                                             | `Boolean</api/data_types/boolean>`       |        |
| `RowFromXY<listbox.rowfromxy>`                     | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                            | `Integer</api/data_types/integer>`       |        |
| `RowImageAt<listbox.rowimageat>`                   | RowNumber As `Integer</api/data_types/integer>`                                                                                             | `Picture</api/graphics/picture>`         |        |
| `Rows<listbox.rows>`                               |                                                                                                                                             | `ListBoxRow</api/deprecated/listboxrow>` |        |
| `RowTagAt<listbox.rowtagat>`                       | Row As `Integer</api/data_types/integer>`                                                                                                   | `Variant</api/data_types/variant>`       |        |
| `SetFocus<listbox.setfocus>`                       |                                                                                                                                             |                                          |        |
| `Sort<listbox.sort>`                               |                                                                                                                                             |                                          |        |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                       | Parameters                                                                                                                                                                                                                                                                                                                                                                                                               | Returns                            |
|------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
| `CellAction<listbox.cellaction>`                           | Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                  |                                    |
| `CellBackgroundPaint<listbox.cellbackgroundpaint>`         | g As `Graphics</api/graphics/graphics>`, Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                         | `Boolean</api/data_types/boolean>` |
| `CellClick<listbox.cellclick>`                             | Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`, X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                | `Boolean</api/data_types/boolean>` |
| `CellGotFocus<listbox.cellgotfocus>`                       | Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                  |                                    |
| `CellKeyDown<listbox.cellkeydown>`                         | Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`, Key As `String</api/data_types/string>`                                                                                                                                                                                                                                                                                         | `Boolean</api/data_types/boolean>` |
| `CellLostFocus<listbox.celllostfocus>`                     | Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                  |                                    |
| `CellTextChange<listbox.celltextchange>`                   | Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                  |                                    |
| `CellTextPaint<listbox.celltextpaint>`                     | g As `Graphics</api/graphics/graphics>`, Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`                                                                                                                                                                                                       | `Boolean</api/data_types/boolean>` |
| `Change<listbox.change>`                                   |                                                                                                                                                                                                                                                                                                                                                                                                                          |                                    |
| `Close<listbox.close_event>`                               |                                                                                                                                                                                                                                                                                                                                                                                                                          |                                    |
| `CollapseRow<listbox.collapserow>`                         | Row As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                                                                |                                    |
| `CompareRows<listbox.comparerows>`                         | Row1 As `Integer</api/data_types/integer>`, Row2 As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` Result As `Integer</api/data_types/integer>`                                                                                                                                                                                                          | `Boolean</api/data_types/boolean>` |
| `ConstructContextualMenu<listbox.constructcontextualmenu>` | Base As `MenuItem</api/deprecated/menuitem>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                           | `Boolean</api/data_types/boolean>` |
| `ContextualMenuAction<listbox.contextualmenuaction>`       | HitItem As `MenuItem</api/deprecated/menuitem>`                                                                                                                                                                                                                                                                                                                                                                          | `Boolean</api/data_types/boolean>` |
| `DisclosureWidgetPaint<listbox.disclosurewidgetpaint>`     | g As `Graphics</api/graphics/graphics>`, row As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` x As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` y As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` width As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` height As `Integer</api/data_types/integer>`                                      |                                    |
| `DoubleClick<listbox.doubleclick>`                         |                                                                                                                                                                                                                                                                                                                                                                                                                          |                                    |
| `DragEnter<listbox.dragenter>`                             | obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                    | `Boolean</api/data_types/boolean>` |
| `DragExit<listbox.dragexit>`                               | obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                    |                                    |
| `DragOver<listbox.dragover>`                               | x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                  | `Boolean</api/data_types/boolean>` |
| `DragOverRow<listbox.dragoverrow>`                         | x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, obj As `DragItem</api/user_interface/desktop/dragitem>`, action As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` row As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` parentRow As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` location As `ListBox<listbox.droplocations>` |                                    |
| `DragReorderRows<listbox.dragreorderrows>`                 | NewPosition As `Integer</api/data_types/integer>`, ParentRow As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                       | `Boolean</api/data_types/boolean>` |
| `DragRow<listbox.dragrow>`                                 | Drag As `DragItem</api/user_interface/desktop/dragitem>`, Row As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                      | `Boolean</api/data_types/boolean>` |
| `DropObject<listbox.dropobject>`                           | Obj As `DragItem</api/user_interface/desktop/dragitem>` Action As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                     |                                    |
| `DropObjectOnRow<listbox.dropobjectonrow>`                 | x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, obj As `DragItem</api/user_interface/desktop/dragitem>`, action As `Integer</api/data_types/integer>`, row As `Integer</api/data_types/integer>`, parentRow As `Integer</api/data_types/integer>`, location As `ListBox<listbox.droplocations>`                                                                                        |                                    |
| `EnableMenuItems<listbox.enablemenuitems>`                 |                                                                                                                                                                                                                                                                                                                                                                                                                          |                                    |
| `ExpandRow<listbox.expandrow>`                             | Row As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                                                                |                                    |
| `GotFocus<listbox.gotfocus>`                               |                                                                                                                                                                                                                                                                                                                                                                                                                          |                                    |
| `HeaderBackgroundPaint<listbox.headerbackgroundpaint>`     | g As `Graphics</api/graphics/graphics>`, column As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                    |                                    |
| `HeaderContentPaint<listbox.headercontentpaint>`           | g As `Graphics</api/graphics/graphics>`, column As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                    |                                    |
| `HeaderPressed<listbox.headerpressed>`                     | Column As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                                                             | `Boolean</api/data_types/boolean>` |
| `KeyDown<listbox.keydown>`                                 | Key As `String</api/data_types/string>`                                                                                                                                                                                                                                                                                                                                                                                  | `Boolean</api/data_types/boolean>` |
| `KeyUp<listbox.keyup>`                                     | Key As `String</api/data_types/string>`                                                                                                                                                                                                                                                                                                                                                                                  |                                    |
| `LostFocus<listbox.lostfocus>`                             |                                                                                                                                                                                                                                                                                                                                                                                                                          |                                    |
| `MouseDown<listbox.mousedown>`                             | x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                         | `Boolean</api/data_types/boolean>` |
| `MouseDrag<listbox.mousedrag>`                             | x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                         |                                    |
| `MouseEnter<listbox.mouseenter>`                           |                                                                                                                                                                                                                                                                                                                                                                                                                          |                                    |
| `MouseExit<listbox.mouseexit>`                             |                                                                                                                                                                                                                                                                                                                                                                                                                          |                                    |
| `MouseMove<listbox.mousemove>`                             | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                         |                                    |
| `MouseUp<listbox.mouseup>`                                 | x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                         |                                    |
| `MouseWheel<listbox.mousewheel>`                           | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`, DeltaX As `Integer</api/data_types/integer>`, DeltaY As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                             | `Boolean</api/data_types/boolean>` |
| `Open<listbox.open>`                                       |                                                                                                                                                                                                                                                                                                                                                                                                                          |                                    |
| `SortColumn<listbox.sortcolumn>`                           | Column As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                                                             | `Boolean</api/data_types/boolean>` |

## Constants

The following class constants of the `DragItem</api/user_interface/desktop/dragitem>` class can be used with `HeaderAt<listbox.headerat>` to specify that a method should apply to all columns or rows rather than a specific column or row.

| Class Constant |
|----------------|
| AllColumns     |
| AllRows        |

## Enumerations

<div id="listbox.alignments">

<div class="rst-class">

forsearch

</div>

</div>

ListBox.Alignments

### Alignments

Specifies all possible cell value alignments.

| Enum    | Description                                          |
|---------|------------------------------------------------------|
| Default | The OS-specific default alignment.                   |
| Left    | The cell value will be left-justified.               |
| Center  | The cell value will be center-aligned.               |
| Right   | The cell value will be right-justified.              |
| Decimal | The cell value will be aligned to the decimal point. |

<div id="listbox.borders">

<div class="rst-class">

forsearch

</div>

</div>

ListBox.Borders

### Borders

Specifies all possible border-styles types for cells.

| Enum            | Description                                                     |
|-----------------|-----------------------------------------------------------------|
| Default         | The type of border unless otherwise specified. Default is None. |
| None            | No border line is drawn.                                        |
| ThinDotted      | A thin, dotted line.                                            |
| ThinSolid       | A thin, solid line.                                             |
| ThickSolid      | A thick, solid line.                                            |
| DoubleThinSolid | Two thin, solid lines.                                          |

<div id="listbox.celltypes">

<div class="rst-class">

forsearch

</div>

</div>

ListBox.CellTypes

### CellTypes

Used to indicate the type of cell.

| Enum      | Description                                                                |
|-----------|----------------------------------------------------------------------------|
| Default   | The default type for a cell. The default is Normal.                        |
| Normal    | A cell that can't be edited directly by the end user.                      |
| CheckBox  | The cell contains only a checkbox.                                         |
| TextField | A cell that can be edited by the end user allowing a single line of text.  |
| TextArea  | A cell that can be edited by the end user allowing multiple lines of text. |

<div id="listbox.droplocations">

<div class="rst-class">

forsearch

</div>

</div>

ListBox.DropLocations

### DropLocations

Used to indicate where on the <span class="title-ref">ListBox</span> an object was dropped.

| Enum         | Description                                                                                                                                                                                                                                           |
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| OnRow        | The drop is occurring on the row itself.                                                                                                                                                                                                              |
| AfterRow     | The drop is occurring between rows, after the row specified. The row can be in the range of \[-1, RowCount-1\] and specifying -1 will insert it at the top of all the rows. This value will also be RowCount-1 if the user drags below the item list. |
| AfterAllRows | The drop is occurring after all rows in the list.                                                                                                                                                                                                     |
| OnRow        | The drop is occurring on the entire control, not on a particular row. This matches the previous behavior.                                                                                                                                             |

<div id="listbox.rowselectiontypes">

<div class="rst-class">

forsearch

</div>

</div>

ListBox.RowSelectionTypes

### RowSelectionTypes

Used to indicate if the selection can be one or more rows.

| Enum     | Description                                          |
|----------|------------------------------------------------------|
| Single   | Only one row is selectable at a time.                |
| Multiple | Any number of rows may be selected at the same time. |

<div id="listbox.sortdirections">

<div class="rst-class">

forsearch

</div>

</div>

ListBox.SortDirections

### SortDirections

Used to indicate if a column's sorting should be ascending, descending or none.

| Enum       | Description                                         |
|------------|-----------------------------------------------------|
| Descending | Rows are sorted in reverse alphabetical order.      |
| None       | The rows are unsorted.                              |
| Ascending  | The rows are sorted in standard alphabetical order. |

<div id="listbox.sorttypes">

<div class="rst-class">

forsearch

</div>

</div>

ListBox.SortTypes

### SortTypes

Specifies whether or not a listbox column is sortable by the end user.

| Enum       | Description                                                                                                    |
|------------|----------------------------------------------------------------------------------------------------------------|
| Sortable   | The column header includes a widget allowing the end user to sort the contents of the column.                  |
| Unsortable | The column header does not include a sorting widget, preventing the end user form sorting the column contents. |

## Property descriptions

<div id="listbox.active">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Active

**Active** As `Boolean</api/data_types/boolean>`

Indicates whether the `RectControl</api/deprecated/rectcontrol>` is active.

This property is read-only.

Active is `False</api/language/false>` when the `RectControl</api/deprecated/rectcontrol>`'s window is not in the foreground. When a `Window</api/deprecated/window>` is deactivated, its controls are automatically deactivated unless `AutoDeactivate<rectcontrol.allowautodeactivate>` is set to `False</api/language/false>`.

<div id="listbox.activetextcontrol">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ActiveTextControl

**ActiveTextControl** As `TextEdit</api/deprecated/textedit>`

The `TextArea</api/deprecated/textarea>` or `TextField</api/deprecated/textfield>` that the <span class="title-ref">ListBox</span> uses for its editable cell operations.

This property is read-only.

The `TextEdit</api/deprecated/textedit>` can be either a `TextField</api/deprecated/textfield>` or a `TextArea</api/deprecated/textarea>` control. To specify which one, the <span class="title-ref">ListBox</span> uses the two following `ListBox<listbox.celltypes>` values:

``` xojo
ListBox.CellTypes.TextArea
ListBox.CellTypes.TextField
```

For example,

``` xojo
ListBox1.CellTypeAt(1,0) = ListBox.CellTypes.TextField
```

To get this `TextField</api/deprecated/textfield>`, you must put the cell into the Inline Editable mode via the `CellTypeAt<listbox.celltypeat>` or `ColumnTypeAt<listbox.columntypeat>` properties and make it editable by calling the `EditCellAt<listbox.editcellat>` method. You can use this property to set or get the text of the <span class="title-ref">ListBox</span> cell (using `SelectedText<textedit.selectedtext>`), set the selection, or change other properties of the <span class="title-ref">ListBox</span>'s `TextField</api/deprecated/textfield>`.

<div id="listbox.allowautodeactivate">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AllowAutoDeactivate

**AllowAutoDeactivate** As `Boolean</api/data_types/boolean>`

Determines whether the control should be deactivated (on macOS) when the parent window is deactivated. The default is `True</api/language/true>`.

<div id="listbox.allowautohidescrollbars">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AllowAutoHideScrollbars

**AllowAutoHideScrollbars** As `Boolean</api/data_types/boolean>`

Controls whether scrollbars are shown when scrolling is not necessary to bring additional text into view. The default is `True</api/language/true>`.

The vertical scroll does not appear until there are more items in the <span class="title-ref">ListBox</span> than can be viewed at once. If AllowAutoHideScrollbars is `False</api/language/false>`, then inactive scrollbars are shown until they are needed to bring additional text into view. AllowAutoHideScrollbars can be set at design time or runtime.

This example turns off AllowAutoHideScrollbars.

``` xojo
Me.AllowAutoHideScrollbars = False
```

<div id="listbox.allowexpandablerows">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AllowExpandableRows

**AllowExpandableRows** As `Boolean</api/data_types/boolean>`

Allows for disclosure triangles for rows added via the AddExpandableRow method.

On Windows, plus and minus signs are used instead of disclosure triangles.

<div id="listbox.allowfocusring">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AllowFocusRing

**AllowFocusRing** As `Boolean</api/data_types/boolean>`

If `True</api/language/true>`, the control indicates when it has the focus by drawing a ring around its border. If `False</api/language/false>`, the appearance of the control does not change when it has the focus.

<div id="listbox.allowresizablecolumns">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AllowResizableColumns

**AllowResizableColumns** As `Boolean</api/data_types/boolean>`

If `True</api/language/true>`, the user can resize columns by moving the pointer over a column divider and dragging to the left or right.

This property is read-only.

When the pointer is over a divider, it changes to an East-West Splitter pointer to indicate that the user can drag the divider. If AllowResizableColumns is `False</api/language/false>`, the pointer does not change its shape.

This example enables the resizable feature.

``` xojo
Me.AllowResizableColumns = True
```

<div id="listbox.allowrowdragging">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AllowRowDragging

**AllowRowDragging** As `Boolean</api/data_types/boolean>`

Allows rows to be dragged.

The following example allows the user to drag one row from ListBox1 to ListBox2. ListBox1 has its AllowRowDragging property set to `True</api/language/true>` and its RowSelectionType property set to zero (Single). Its DragRow event handler is as follows:

``` xojo
Function DragRow(drag As DragItem, row As Integer) As Boolean
  drag.Text = Me.List(row)
  Return True ' allow the drag
```

ListBox2's Open event handler has the line:

``` xojo
Me.AcceptTextDrop
```

Its DropObject event handler is this:

``` xojo
Sub DropObject(obj As DragItem)
  Me.AddRow(obj.Text) ' adds the dropped text as a new row
```

The following example allows the user to drag more than one row from ListBox1 to ListBox2. The dragged rows are added to the end of the list.

ListBox1 has its AllowRowDragging property set to `True</api/language/true>`, enabling items in its list to be dragged, and its RowSelectionType property set to 1 (Multiple row selection). Its DragRow event handler is as follows:

``` xojo
Function DragRow (drag As DragItem, row As Integer) As Boolean
  Var nRows, i As Integer
  nRows = Me.RowCount - 1
  For i = 0 To nRows
    If Me.Selected(i) Then
      drag.AddItem(0, 0, 20, 4)
      drag.Text = Me.List(i) ' get text
    End If
  Next
  Return True ' allow the drag
End Function
```

It uses the AddItem method of the `DragItem</api/user_interface/desktop/dragitem>` to add an additional item to the DragItem each selected row. The DropObject event handler then cycles through all items to retrieve all dragged rows.

ListBox2 has the following line of code in its Open event handler. It permits it to receive dragged text.

``` xojo
Me.AcceptTextDrop
```

Its DropObject event handler checks to see if the dragged object is text; if it is, it adds a row to the end of the list and assigns the text property of the dragged object to the new row: It loops through all items in the DragItem until NextItem returns `False</api/language/false>`.

``` xojo
Sub DropObject(obj As DragItem)
  Do
    If obj.TextAvailable Then
      Me.AddRow(obj.Text)
    End If
  Loop Until Not obj.NextItem
End Sub
```

<div id="listbox.allowrowreordering">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AllowRowReordering

**AllowRowReordering** As `Boolean</api/data_types/boolean>`

If `True</api/language/true>`, you can reorder rows within the <span class="title-ref">ListBox</span> by dragging rows.

An insertion line indicator appears when dragging within the <span class="title-ref">ListBox</span> to provide you with visual feedback as to where the row would be dropped if you release the mouse button. .. note:: You cannot drag rows on a <span class="title-ref">ListBox</span> with expandable rows (hierarchical) and as a result, setting this property to True has no effect.

This example enables the drag reorder feature.

``` xojo
Me.AllowRowReordering = True
```

<div id="listbox.allowtabstop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AllowTabStop

**AllowTabStop** As `Boolean</api/data_types/boolean>`

If `True</api/language/true>`, the **RectControl** is in the Tab Order and accepts the focus when the user tabs into it. The default is `True</api/language/true>`. If `False</api/language/false>`, the user cannot tab into it to give it the focus. However, the **RectControl** can gain the focus by other means, such as the user's clicking on it or by setting the focus in code.

This example removes the control from the Tab Order:

``` xojo
Me.AllowTabStop = False
```

<div id="listbox.bold">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Bold

**Bold** As `Boolean</api/data_types/boolean>`

If `True</api/language/true>`, applies the bold style to the control's caption and/or its text content if any.

Mac apps can only display font styles that are available. You cannot force a font to display in bold or italic if it does not have bold or italic variations available. In this situation, the Bold property will not affect the font.

<div id="listbox.cellalignmentat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellAlignmentAt

**CellAlignmentAt** As `Integer</api/data_types/integer>`

Aligns the specified cell. *Row* and *Column* are zero-based.

You specify the alignment via `ListBox<listbox.alignments>`.

Decimal aligns the decimal separator to the right edge of the cell. You need to use `CellAlignmentOffsetAt<listbox.cellalignmentoffsetat>` or `ColumnAlignmentOffsetAt<listbox.columnalignmentoffsetat>` to move the data into the column.

``` xojo
Listbox1.CellAlignmentAt(1,1) = ListBox.Alignments.Right
```

<div id="listbox.cellalignmentoffsetat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellAlignmentOffsetAt

**CellAlignmentOffsetAt** As `Integer</api/data_types/integer>`

The value is the distance in points from the right edge of the cell. *Row* and *Column* are zero-based. This property overrides ColumnAlignmentOffsetAt for that cell.

Any value specified here is applied to the value used for ColumnAlignmentOffset.

This code is applied to a column that is right-aligned and moves the contents of a cell 10 points to the left.

``` xojo
Me.CellAlignmentOffsetAt(1, 3) = -10
```

<div id="listbox.cellborderbottomat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellBorderBottomAt

**CellBorderBottomAt** As `Integer</api/data_types/integer>`

Sets the bottom border of the cell designated by *Row*, *Column* to a rule style. *Row* and *Column* are zero-based.

You specify the Border via `ListBox<listbox.borders>`.

The following example sets the bottom border of a cell to Thin Solid.

``` xojo
ListBox1.CellBorderBottomAt(1, 1) = ListBox.Borders.ThinSolid
```

<div id="listbox.cellborderleftat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellBorderLeftAt

**CellBorderLeftAt** As `Integer</api/data_types/integer>`

Sets the left border of the cell designated by *Row*, *Column* to a rule style. *Row* and *Column* are zero-based.

You specify the Border via `ListBox<listbox.borders>`.

The following example sets the border of a cell to Thin Solid.

``` xojo
ListBox1.CellBorderLeftAt(1, 1) = ListBox.Borders.ThinSolid
```

<div id="listbox.cellborderrightat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellBorderRightAt

**CellBorderRightAt** As `Integer</api/data_types/integer>`

Sets the right border of the cell designated by *Row*, *Column* to a rule style. *Row* and *Column* are zero-based.

You specify the Border via `ListBox<listbox.borders>`.

The following example sets the right border of a cell to Thin Solid.

``` xojo
ListBox1.CellBorderRightAt(1, 1) = ListBox.Borders.ThinSolid
```

<div id="listbox.cellbordertopat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellBorderTopAt

**CellBorderTopAt** As `Integer</api/data_types/integer>`

Sets the top border of the cell designated by *Row*, *Column* to a rule style. *Row* and *Column* are zero-based.

You specify the Border via `ListBox<listbox.borders>`.

The following example sets the top border of a cell to Thin Solid.

For example:

``` xojo
ListBox1.CellBorderTopAt(1, 1) = ListBox.Borders.ThinSolid
```

<div id="listbox.cellcheckboxvalueat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellCheckBoxValueAt

**CellCheckBoxValueAt** As `Boolean</api/data_types/boolean>`

Checks or unchecks the checkbox in the passed cell. *Row* and *Column* are zero-based.

Setting CellCheckBoxValueAt to `True</api/language/true>` checks the checkbox.

<div id="listbox.celltypeat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellTypeAt

**CellTypeAt** As `Integer</api/data_types/integer>`

Sets the type of the passed cell. *Row* and *Column* are zero-based.

The cell type can be set with `ListBox<listbox.celltypes>`.

This code shows a checkbox in a single cell:

``` xojo
ListBox1.CellTypeAt(0, 4) = Listbox.CellTypes.Checkbox ' Cell in the 1st row, 5th column now shows a checkbox
```

To set or use the value of the Cell's checkbox see both the `CellCheckBoxValueAt<listbox.cellcheckboxvalueat>` property (boolean) and `CellCheckBoxStateAt<listbox.cellcheckboxstateat>` method (CheckedUncheckedIndeterminate). This code uses CellCheckboxStateAt to set the cell to be checked:

``` xojo
ListBox1.CellCheckBoxStateAt(0, 4) = CheckBox.VisualStates.Checked
```

<div id="listbox.columnalignmentat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ColumnAlignmentAt

**ColumnAlignmentAt** As `Integer</api/data_types/integer>`

Aligns the specified column. The first column is numbered zero.

You specify the alignment via the `ListBox<listbox.alignments>` enumeration.

Set right alignment:

``` xojo
ListBox1.ColumnAlignmentAt(1) = ListBox.Alignments.Right
```

<div id="listbox.columnalignmentoffsetat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ColumnAlignmentOffsetAt

**ColumnAlignmentOffsetAt** As `Integer</api/data_types/integer>`

Modifies the alignment point and is especially useful for decimal alignment. The first column is numbered zero.

The value is the distance in points from what is specified for the column alignment.

For right alignment, a negative value moves the decimal separator to the left, i.e., into the body of the column. See the example in the Notes subsection "Decimal Alignment."

ListBox columns are zero-based.

This code sets the offset in a right-aligned column by 10 points.

``` xojo
Me.ColumnAlignmentOffsetAt(2) = -10
```

<div id="listbox.columnat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ColumnAt

**ColumnAt** As `ListColumn</api/deprecated/listcolumn>`

Enables you to access the `ListColumn</api/deprecated/listcolumn>` properties of the specified column. The first column is numbered zero.

Use <span class="title-ref">ListBox</span>.AllColumns to refer to all columns.

<div id="listbox.columncount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ColumnCount

**ColumnCount** As `Integer</api/data_types/integer>`

The number of columns the <span class="title-ref">ListBox</span> contains. The maximum number of columns is 256.

Setting this value higher than 255, will result in the ColumnCount being set to 256.

Adding a column to ListBox1 and setting the widths of the columns to 50 and 65 pixels, respectively:

``` xojo
ListBox1.ColumnCount = 2
ListBox1.ColumnWidths = "50,65"
```

Setting the number of columns of ListBox1 to three and setting the widths of the columns to 60%, 20% and 20% respectively:

``` xojo
ListBox1.ColumnCount = 3
ListBox1.ColumnWidths = "60%,20%,20%"
```

<div id="listbox.columnsortdirectionat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ColumnSortDirectionAt

**ColumnSortDirectionAt** As `Integer</api/data_types/integer>`

Used to get or set the sort direction for the passed column. The first column is numbered zero.

You set the sort direction using `ListBox<listbox.sortdirections>`.

This example sets the sort direction for a column.

``` xojo
ListBox1.ColumnSortDirectionAt(2) = ListBox.SortDirections.Descending
```

<div id="listbox.columntypeat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ColumnTypeAt

**ColumnTypeAt** As `Integer</api/data_types/integer>`

Sets the type for the passed column. The first column is numbered zero.

Column types are set using `ListBox<listbox.celltypes>`.

The following makes a column editable:

``` xojo
lb1.ColumnTypeAt(1) = ListBox.CellTypes.TextField
```

Disclosure triangles don't work in hierarchical ListBoxes if the CellType is TextField or TextArea. ColumnTypeAt can be overridden by CellType.

The following example makes a column a checkbox column and sets two of the values:

``` xojo
Me.ColumnTypeAt(4) = Listbox.CellTypes.Checkbox
Me.CellCheckBoxStateAt(0, 4) = CheckBox.VisualStates.Indeterminate
Me.CellCheckBoxStateAt(1, 4) = Checkbox.VisualStates.Checked 
```

.

<div id="listbox.columnwidths">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ColumnWidths

**ColumnWidths** As `String</api/data_types/string>`

A list of comma-separated values, with each value controlling the width of the associated column. A value can be an absolute value (in points), a percentage, a relative length expressed as *i*\* where *i* is an integer, or an "\*" that indicates "fill in the remaining width." If you use percentages, you can use non-integer values to specify fractions of a percent, e.g., 43.52%. The percentage value can be greater than 100%.

If you use points, the last column doesn't grow to the size of the rest of the <span class="title-ref">ListBox</span>. You should set the width of the last column to "\*" and it will automatically take up the remaining width of the <span class="title-ref">ListBox</span>.

Without any column width specifications, the headers will be divided evenly. If there are fewer column widths specified than the total number of columns, the remaining columns will divide up the remaining width equally.

An element with a length of "3\*" will be allotted three times the space of an element with length "1\*". The value "*" is equivalent to "1*" and can be used to mean "fill the remaining space."

You can use a mixture of points, percentages, and relative lengths. Column widths specified in pixels are guaranteed to have the specified width. Column widths specified in percentages are guaranteed to have that percentage of the visible width of the <span class="title-ref">ListBox</span>. The column widths specified using the \* divide up the remaining width proportionally. For example, if there are four columns, the specification 20, 20%, *, 2* gives 20 points to the first column 20% of the total to the second column, and the last two columns divide up the remaining width in the ratio of 1:2, with the last column getting any remaining fractional pixels.

Unrecognized or unsupported expressions (e.g. '2@')for the column width properties will result in an `UnsupportedFormatException</api/exceptions/unsupportedformatexception>`. The message of this exception describes in English what went wrong.

Resizing a column will resize the value of the expression. If you resize the <span class="title-ref">ListBox</span>, both the percentage and relative lengths recompute their actual widths. There are two resizing "modes"; see notes.

Header End caps are added for any additional unused space if headers are used. Header end caps do nothing when clicked.

Adding a column to ListBox1 and setting the widths of the columns to 50 and 65 points, respectively:

``` xojo
ListBox1.ColumnCount = 2
ListBox1.ColumnWidths = "50,65"
```

Setting the number of columns of ListBox1 to three and setting the widths of the columns to 60%, 20% and 20% respectively:

``` xojo
ListBox1.ColumnCount = 3
ListBox1.ColumnWidths = "60%,20%,20%"
```

If ListBox1 is 100 pixels wide and has three columns, the following code will set the columns widths as indicated but the last column will only be 10 points wide instead of 20:

``` xojo
ListBox1.ColumnWidths = "60,30,20"
```

If ListBox1 is 100 points wide and has three columns, the following code will set the columns widths but the last column will not be displayed:

``` xojo
ListBox1.ColumnWidths = "60,40,20"
```

<div id="listbox.defaultrowheight">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.DefaultRowHeight

**DefaultRowHeight** As `Integer</api/data_types/integer>`

Determines the height of every row in the <span class="title-ref">ListBox</span> in points. Every row in the <span class="title-ref">ListBox</span> is always the same height.

Use a value of -1 to have the height automatically determined by the current font size.

This example increases the default row height.

``` xojo
Me.DefaultRowHeight = 35
```

<div id="listbox.dropindicatorvisible">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.DropIndicatorVisible

**DropIndicatorVisible** As `Boolean</api/data_types/boolean>`

Determines whether or not the drop indicators appears. This property changes the appearance of the <span class="title-ref">ListBox</span>. It does not prevent the new events from firing.

<div id="listbox.enabled">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Enabled

**Enabled** As `Boolean</api/data_types/boolean>`

Determines if the control should be enabled when the owning window is opened.

A disabled control cannot be clicked and cannot receive the focus.

This example disables the control. Its caption is grayed out.

``` xojo
Me.Enabled = False
```

<div id="listbox.fontname">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.FontName

**FontName** As `String</api/data_types/string>`

Name of the font used to display text.

You can enter any font that is installed on the computer or the names of the two metafonts, "System" and "SmallSystem".

The System font is the font used by the system software as its default font. Different operating systems use different default fonts. If the system software supports both a large and small System font, you can also specify the "SmallSystem" font as your TextFont.

On macOS, "SmallSystem" specifies the OS's smaller system font and may make the control smaller in size as well. On Windows and Linux, "SmallSystem" is the same as "System".

This code sets the FontName property.

``` xojo
Me.FontName = "Helvetica"
```

<div id="listbox.fontsize">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.FontSize

**FontSize** As `Single</api/data_types/single>`

Size of the font used to display text.

If you enter zero as the FontSize, your app will use the font size that works best for the platform on which it is running.

This code sets the font size to 16.

``` xojo
Me.FontSize = 16
```

<div id="listbox.fontunit">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.FontUnit

**FontUnit** As `FontUnits</api/graphics/fontunits>`

The units in which FontSize is measured.

<div id="listbox.gridlineshorizontalstyle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.GridLinesHorizontalStyle

**GridLinesHorizontalStyle** As `Integer</api/data_types/integer>`

Draws horizontal lines between rows in the selected style.

The style for the borders is selected using `ListBox<listbox.borders>`.

This example sets the gridlines to Thin Solid. The example is in the Open event of the <span class="title-ref">ListBox</span>.

``` xojo
Me.GridLinesHorizontalStyle = ListBox.Borders.ThinSolid
```

<div id="listbox.gridlinesverticalstyle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.GridLinesVerticalStyle

**GridLinesVerticalStyle** As `Integer</api/data_types/integer>`

Draws vertical lines between columns based on the selected style.

The style for the borders is selected using `ListBox<listbox.borders>`.

This example sets the vertical lines to Thin Solid. The code is in the Open event of the control.

``` xojo
Me.GridLinesVerticalStyle = ListBox.Borders.ThinSolid
```

<div id="listbox.handle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Handle

**Handle** As `Integer</api/data_types/integer>`

Returns a handle to the control.

This property is read-only.

For interfacing with Mac APIs using `` Declare</api/language/declare>`s, RectControl.Handle returns NSViews (except for :doc:`Toolbar</api/deprecated/toolbar> ``).

On Windows returns the HWND of the control.

On Linux it returns a GtkWidget.

The following gets a handle to the control.

``` xojo
Var i As Integer = Me.Handle
```

<div id="listbox.hasborder">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.HasBorder

**HasBorder** As `Boolean</api/data_types/boolean>`

Indicates whether or not the border is visible.

<div id="listbox.hasheader">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.HasHeader

**HasHeader** As `Boolean</api/data_types/boolean>`

If `True</api/language/true>`, a row of column headers is added to the <span class="title-ref">ListBox</span>. The user can sort the column by clicking the heading if `ColumnSortDirectionAt<listbox.columnsortdirectionat>` is true not set to None for that column.

The following example shows the Headers row. The code is in the Open event of the control.

``` xojo
Me.HasHeader = True
```

<div id="listbox.hashorizontalscrollbar">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.HasHorizontalScrollbar

**HasHorizontalScrollbar** As `Boolean</api/data_types/boolean>`

If `True</api/language/true>`, adds a horizontal scrollbar to the <span class="title-ref">ListBox</span>.

The horizontal scrollbar only appears if the sum of the widths of the columns exceeds the width of the <span class="title-ref">ListBox</span> itself. If the widths of the columns is less than (or matches) the width of the <span class="title-ref">ListBox</span>, then no horizontal scrollbar appears.

The position of the thumb is indicated by ScrollPositionX. It is used to scroll the <span class="title-ref">ListBox</span> horizontally without a separate `Scrollbar</api/deprecated/scrollbar>` control.

<div id="listbox.hasverticalscrollbar">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.HasVerticalScrollbar

**HasVerticalScrollbar** As `Boolean</api/data_types/boolean>`

If `True</api/language/true>`, adds a vertical scrollbar to the <span class="title-ref">ListBox</span>. The position of the thumb is indicated by ScrollPosition. The default is `True</api/language/true>`.

<div id="listbox.headerheight">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.HeaderHeight

**HeaderHeight** As `Integer</api/data_types/integer>`

The height of the header row in pixels.

This example displays the height of the header row. It is in the Action event of a button control.

``` xojo
Var h As Integer = Listbox1.HeaderHeight
```

<div id="listbox.headingindex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.HeadingIndex

**HeadingIndex** As `Integer</api/data_types/integer>`

Allows you to get and set the sort column in a <span class="title-ref">ListBox</span>. The first column is numbered zero.

Using this property sets the sort direction indicator in the header.

You can also sort a <span class="title-ref">ListBox</span> by using the `SortedColumn<listbox.sortingcolumn>` property to set the sort column and the `ColumnSortDirection<listbox.columnsortdirectionat>` property to set the direction of the sort. Then call the `Sort<listbox.sort>` method to do the sort.

This code in the Open event of a <span class="title-ref">ListBox</span> sorts on the first column:

``` xojo
Me.SortedColumn = 0
Me.ColumnSortDirectionAt(0) = ListBox.SortDirections.Ascending
Me.HeadingIndex = 0
Me.Sort
```

<div id="listbox.height">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Height

**Height** As `Integer</api/data_types/integer>`

The height (in points) of the control.

This example sets the height of the control to 100:

``` xojo
Me.Height = 100
```

<div id="listbox.index">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Index

**Index** As `Integer</api/data_types/integer>`

If the control is used in a control set, this specifies the control's index in the set.

This property is read-only.

The *control set* is often used to manage a group of RadioButtons since a single RadioButton in a window doesn't make much sense. Most typically, you create an instance of the RadioButton, assign 0 to its Index property, and then duplicate it. This increments the value of Index for each new instance but retain the original control's name.

To determine which RadioButton the user clicked, use the Action event handler of the control set. The parameter *Index* contains the value of Index for the RadioButton that was clicked. The event handler is this:

``` xojo
Sub Action(Index As Integer)
  Label1.Text = "You chose radio button " + index.ToString + "."
End Sub
```

To set a RadioButton in a control set, you use its *Index* property to refer to the RadioButton whose value you want to set. For example, the following line selects the second RadioButton from code:

``` xojo
RadioButton1(1).Value = True ' 0-based
```

<div id="listbox.initialvalue">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.InitialValue

**InitialValue** As `String</api/data_types/string>`

A list of the default items separated by returns.

If the <span class="title-ref">ListBox</span> has more than one column (ColumnCount \> 1), separate column entries with Tabs within each row. If HasHeading is `True</api/language/true>`, the first row of InitialValue is assumed to be the column headings -- unless the Heading array is also specified.

<div id="listbox.italic">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Italic

**Italic** As `Boolean</api/data_types/boolean>`

If `True</api/language/true>`, applies the italic style to the control's caption and/or its text content if any.

Mac apps can only display font styles that are available. You cannot force a font to display in bold or italic if it does not have bold or italic variations available. In this situation, the Italic property will not affect the font.

<div id="listbox.lastaddedrowindex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.LastAddedRowIndex

**LastAddedRowIndex** As `Integer</api/data_types/integer>`

The number of the last row added with the AddRow, AddExpandableRow, or AddRowAt method. LastAddedRowIndex is zero-based. If no rows have been added, LastAddedRowIndex will be the <span class="title-ref">ListBox</span>.None constant (-1). Use this to get the row number when getting or setting values in a multi-column <span class="title-ref">ListBox</span>. See the section on Multi-column listboxes in the Notes section.

This property is read-only.

This example project consists of a two-column <span class="title-ref">ListBox</span> and two `TextFields</api/deprecated/textfield>` for the entry of first and last names. A `PushButton</api/deprecated/pushbutton>` creates a new row in the <span class="title-ref">ListBox</span> and adds the contents of the `TextFields</api/deprecated/textfield>` to the <span class="title-ref">ListBox</span>.

``` xojo
PeopleList.Addrow("")
PeopleList.CellValueAt(PeopleList.LastAddedRowIndex, 0) = FirstNameField.Value
PeopleList.CellValueAt(PeopleList.LastAddedRowIndex, 1) = LastNameField.Value
PeopleList.SelectedIndex = PeopleList.LastAddedRowIndex ' select the newly added row
FirstNameField.SetFocus
```

This code asks the user to add a row if they have not yet done so:

``` xojo
If ListBox1.LastAddedRowIndex = ListBox.None then
 System.Beep
 MessageBox("Please add a row to continue.")
End If
```

<div id="listbox.lastcolumnindex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.LastColumnIndex

**LastColumnIndex** As `Integer</api/data_types/integer>`

The number of the last column of the <span class="title-ref">ListBox</span>. Because the <span class="title-ref">ListBox</span> is zero-based, this value will be 1 less than the `ListBox<listbox.columncount>`.

This property is read-only.

<div id="listbox.lastrowindex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.LastRowIndex

**LastRowIndex** As `Integer</api/data_types/integer>`

The number of the last row of the <span class="title-ref">ListBox</span>. Because the <span class="title-ref">ListBox</span> is zero-based, this value will be 1 less than the `ListBox<listbox.rowcount>`.

This property is read-only.

<div id="listbox.left">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Left

**Left** As `Integer</api/data_types/integer>`

The left side of the control in local coordinates (relative to the window).

The following example moves the control 100 points from the left side of the window:

``` xojo
Me.Left = 150
```

<div id="listbox.list">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.List

**List** As `String</api/data_types/string>`

The list of items. List takes one parameter, the row index. The first row is numbered zero. Use it to get or set the contents of that cell, or, in multi-column ListBoxes, the contents of the first column.

<div id="listbox.lockbottom">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.LockBottom

**LockBottom** As `Boolean</api/data_types/boolean>`

Determines whether the bottom edge of the control should stay at a set distance from the bottom edge of the parent control, if there is one, or the owning window.

This property can be set in the control's Inspector. The following example sets it in code.

``` xojo
Me.LockBottom = True
```

<div id="listbox.lockleft">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.LockLeft

**LockLeft** As `Boolean</api/data_types/boolean>`

Determines whether the left edge of the control should stay at a set distance from the left edge of the parent control, if there is one, or the owning window.

Beginning with version 2009r5, LockLeft and Locktop default to `True</api/language/true>` when you add a new control to a window. Existing controls will be altered only if LockRight and/or LockBottom are not set. *LockLeft* has no effect unless *LockRight* is `True</api/language/true>`.

This property can be set in the control's Inspector. The following example sets it in code.

``` xojo
Me.LockLeft = True
```

<div id="listbox.lockright">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.LockRight

**LockRight** As `Boolean</api/data_types/boolean>`

Determines whether the right edge of the control should stay at a set distance from the right edge of the parent control, if there is one, or the owning window.

This property can be set in the control's Inspector. The following example sets it in code.

``` xojo
Me.LockRight = True
```

<div id="listbox.locktop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.LockTop

**LockTop** As `Boolean</api/data_types/boolean>`

Determines whether the top edge of the control should stay at a set distance from the top edge of the parent control, if there is one, or the owning window.

Beginning with version 2009r5, LockTop and LockLeft default to `True</api/language/true>` when you add a control to a window. Existing controls will be altered only if LockRight and/or LockBottom are not set. *LockTop* has no effect unless *LockBottom* is `True</api/language/true>`.

This property can be set in the control's Inspector. The following example sets it in code.

``` xojo
Me.LockTop = True
```

<div id="listbox.mousecursor">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.MouseCursor

**MouseCursor** As `MouseCursor</api/user_interface/desktop/mousecursor>`

The cursor to be displayed while the mouse is within the control and both the `DesktopApplication</api/user_interface/desktop/desktopapplication>` and `Window</api/deprecated/window>` class's MouseCursor properties are `Nil</api/language/nil>`.

If the `DesktopApplication</api/user_interface/desktop/desktopapplication>` class's MouseCursor property is not `Nil</api/language/nil>` or the `Window</api/deprecated/window>`'s MouseCursor property is not `Nil</api/language/nil>`, then any control's MouseCursor property is ignored. You can use a cursor stored in the `Cursors</api/user_interface/desktop/cursors>` module. On Macintosh, you can also obtain a `MouseCursor</api/user_interface/desktop/mousecursor>` from a resource file.

This line in the Open event of the control sets the default cursor to the finger pointer.

``` xojo
Me.MouseCursor = System.Cursors.FingerPointer
```

<div id="listbox.mousex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.MouseX

**MouseX** As `Integer</api/data_types/integer>`

The X coordinate of the mouse (points). Measured from the top-left corner of the control.

This property is read-only.

This code is in the MouseDown event of a `TextField</api/deprecated/textfield>` and displays the X-coordinate at the point of the MouseDown event.

``` xojo
Me.Value = Str(Me.MouseX)
```

<div id="listbox.mousey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.MouseY

**MouseY** As `Integer</api/data_types/integer>`

The Y coordinate of the mouse (points). Measured from the top-left corner of the control.

This property is read-only.

This code is in the MouseDown event of a `TextField</api/deprecated/textfield>` and displays the Y-coordinate at the point of the MouseDown event.

``` xojo
Me.Value = Str(Me.MouseY)
```

<div id="listbox.name">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Name

**Name** As `String</api/data_types/string>`

The name of the control. Set the name of the control in the Inspector.

This property is read-only.

<div id="listbox.panelindex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.PanelIndex

**PanelIndex** As `Integer</api/data_types/integer>`

If the control has been placed on a `TabPanel</api/deprecated/tabpanel>` or `PagePanel</api/deprecated/pagepanel>` control, this is the panel (page/tab) that the control is on. If the control is not on a panel, it returns -1.

The first panel is numbered zero. If the control has been placed on a panel of a `TabPanel</api/deprecated/tabpanel>` or `PagePanel</api/deprecated/pagepanel>` control, it returns the panel number. If the control is not on a `PagePanel</api/deprecated/pagepanel>` or `TabPanel</api/deprecated/tabpanel>`, it returns -1. If you change the PanelIndex to a nonexistent panel, the control will disappear until you give it a PanelIndex value that corresponds to a panel that exists.

If you are looking to change the currently selected panel (page/tab), use `PagePanel<pagepanel.selectedpanelindex>`.

This code displays the panel index of the control that is on the page.

``` xojo
Label3.Value = Str(Me.PanelIndex)
```

<div id="listbox.parent">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Parent

**Parent** As `Control</api/deprecated/control>`

Used to get and set the control's parent control or window.

Returns `Nil</api/language/nil>` if the parent is the window. Assign `Nil</api/language/nil>` to make the control's parent the window, even if it is enclosed by another control. The child control's behavior in the IDE will reflect the parent's state. If the parent control is somehow in another window, an `InvalidParentException</api/exceptions/invalidparentexception>` will occur.

The following example sets the parent of the control to the window.

``` xojo
Me.Parent = Nil
```

<div id="listbox.requiresselection">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.RequiresSelection

**RequiresSelection** As `Boolean</api/data_types/boolean>`

If `True</api/language/true>`, users will not be able to deselect the last row by clicking below the last visible row or by dragging. You can still deselect the last row by setting the SelectedRowIndex property to <span class="title-ref">ListBox</span>.NoSelection.

<div id="listbox.rowcount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.RowCount

**RowCount** As `Integer</api/data_types/integer>`

The number of rows in the <span class="title-ref">ListBox</span>.

This property is read-only.

<div id="listbox.rowheight">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.RowHeight

**RowHeight** As `Integer</api/data_types/integer>`

Gets the <span class="title-ref">ListBox</span> row height. All rows in a <span class="title-ref">ListBox</span> are always the same height, which you can change using `DefaultRowHeight<listbox.defaultrowheight>`.

This property is read-only.

<div id="listbox.rowselectiontype">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.RowSelectionType

**RowSelectionType** As `Integer</api/data_types/integer>`

Indicates the type of row selection allowed via mouse gestures.

The type of allowed row selection is set via `ListBox<listbox.rowselectiontypes>`.

The default is single-row selection. If multiple row selection is on, a <span class="title-ref">ListBox</span> will handle Edit \> Select All menu item commands by default as long as the Select All menu item is named **EditSelectAll**.

<div id="listbox.scope">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Scope

**Scope** As `Integer</api/data_types/integer>`

Used to determine whether access to the control is Public (0) or Private (2). The default is Public.

This property is read-only.

If the Scope of a control is set to Private, it cannot be accessed from outside its parent window.

<div id="listbox.scrollposition">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ScrollPosition

**ScrollPosition** As `Integer</api/data_types/integer>`

Zero-based index of the top visible row in the <span class="title-ref">ListBox</span>.

Read ScrollPosition to determine the top visible row; write to ScrollPosition to scroll the <span class="title-ref">ListBox</span>. When the scrollbar thumb is scrolled to the bottom, ScrollPosition cannot be incremented any further.

<div id="listbox.scrollpositionx">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ScrollPositionX

**ScrollPositionX** As `Integer</api/data_types/integer>`

Zero-based index of the horizontal position of the <span class="title-ref">ListBox</span>.

<div id="listbox.selected">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Selected

**Selected** As `Boolean</api/data_types/boolean>`

Gets or sets the selection status of the passed *Row*. *Row* is zero-based.

Selected is `True</api/language/true>` if the row passed is selected. This property can be used to determine if the row is selected and to select the row. For example,

``` xojo
Listbox1.Selected(1) = True  //selects the second item in the first column.
```

In order to select multiple row, the `SelectionType<listbox.rowselectiontype>` must be set to Multiple. This code selects only the even-numbered rows:

``` xojo
ListBox1.ListIndex = -1 ' Deselect all rows

For i As Integer = 0 To ListBox1.LastRowIndex
  If i Mod 2 = 0 Then
    ListBox1.Selected(i) = True
  End If
Next
```

If you allow the <span class="title-ref">ListBox</span> to have multiple items selected (see `SelectionType<listbox.rowselectiontype>`), you may want to establish a list of all the rows selected. The following example shows how to achieve that. The <span class="title-ref">ListBox</span> is named *ListBox1*.

``` xojo
Var selectedRows() As Integer ' Will hold the index of each selected row

For row As Integer = 0 To ListBox1.LastRowIndex
  If ListBox1.Selected(row) Then
    selectedRows.AddRow(row) ' This row is selected
  End If
Next
```

<div id="listbox.selectedrowcount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.SelectedRowCount

**SelectedRowCount** As `Integer</api/data_types/integer>`

The number of rows selected (highlighted).

This property is read-only.

<div id="listbox.selectedrowindex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.SelectedRowIndex

**SelectedRowIndex** As `Integer</api/data_types/integer>`

The number of the selected row.

If no item is selected, SelectedRowIndex returns <span class="title-ref">ListBox</span>.NoSelection. If the <span class="title-ref">ListBox</span> is in multiple-row selection mode, then the number of the lowest selected row is returned. For example, if rows 1, 3, and 4 are selected, SelectedRowIndex returns 1.

You can put the <span class="title-ref">ListBox</span> into multiple-row selection mode by changing the `RowSelectionType<listbox.rowselectiontype>` property.

The following code in the `Change<listbox.change>` event handler displays the text in the first column of the selected row:

``` xojo
If Me.SelectedRowIndex >= 0 Then
  MessageBox(Me.CellValueAt(Me.SelectedRowIndex, 0))
End If
```

The following code displays a message if no row is selected:

``` xojo
If ListBox1.SelectedRowIndex = ListBox.NoSelection Then
  MessageBox("Please select a row first.")
End If
```

<div id="listbox.selectedrowvalue">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.SelectedRowValue

**SelectedRowValue** As `String</api/data_types/string>`

The value of the currently selected item.

In the case of multi-column ListBoxes, the value of the cell in the first column is returned.

<div id="listbox.sortingcolumn">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.SortingColumn

**SortingColumn** As `Integer</api/data_types/integer>`

Gets or sets the current sort column but doesn't do the sort. The first column is numbered zero. If no column is sorted then it returns -1. Call the `Sort<listbox.sort>` method to sort the <span class="title-ref">ListBox</span> based on the values of SortingColumn and `ColumnSortDirectionAt<listbox.columnsortdirectionat>`.

The following code in the Pressed event of a Pushbutton asks the user to sort on a column if the <span class="title-ref">ListBox</span> is not sorted by any column:

``` xojo
If Listbox1.SortingColumn = ListBox.None then
 System.Beep
 MessageBox("Please sort the rows by one of the columns.")
End If
```

<div id="listbox.tabindex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.TabIndex

**TabIndex** As `Integer</api/data_types/integer>`

The **RectControl's** position in the Tab Order. It is 0-based. A TabIndex of 0 is the first **RectControl** to get the focus.

On the Mac you need Full Keyboard Access turned on in System Preferences (Keyboard-\>Shortcuts) in order to manually set focus to non-text controls.

This example sets the control's TabIndex.

``` xojo
Me.TabIndex = 2
```

<div id="listbox.tooltip">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Tooltip

**Tooltip** As `String</api/data_types/string>`

Text of help message displayed as a Windows or Linux "tooltip" or macOS help tag.

The tip/tag is displayed when the user hovers the mouse cursor over the control.

This example adds a tooltip to a `BevelButton</api/deprecated/bevelbutton>` that has an icon.

``` xojo
Me.CaptionAlignment = 0 ' left
Me.CaptionDelta = 10
Me.Tooltip = "Click to bark."

Me.Icon = Woof ' added to the project
Me.CaptionPosition = 2
```

<div id="listbox.top">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Top

**Top** As `Integer</api/data_types/integer>`

The top of the control in local coordinates (relative to the window).

This example sets the top of the control to 140 points from the top of the window:

``` xojo
Me.Top = 140
```

<div id="listbox.transparent">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Transparent

**Transparent** As `Boolean</api/data_types/boolean>`

Determines whether the control is transparent on Windows. The default is `False</api/language/false>`. Has no effect on macOS or Linux.

Transparent controls draw more slowly and use more memory in order to cache the background. Unless you absolutely require transparency, leave this set to False.

For projects that were created prior to 2018r1, this property defaults to True to emulate previous behavior. Consider changing it to False to improve performance if you do not require transparency.

<div id="listbox.truewindow">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.TrueWindow

**TrueWindow** As `Window</api/deprecated/window>`

Returns a reference to the actual enclosing `Window</api/deprecated/window>`.

This property is read-only.

TrueWindow walks up the window hierarchy and finds the actual enclosing window regardless of how deeply nested the `RectControl</api/deprecated/rectcontrol>` or `DesktopContainer</api/user_interface/desktop/desktopcontainer>` hierarchy is.

`Window</api/deprecated/window>` also has a TrueWindow property.

This example accesses the TrueWindow and displays its Title property in a `TextField</api/deprecated/textfield>`.

``` xojo
TextField1.Text = Me.TrueWindow.Title
```

<div id="listbox.underline">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Underline

**Underline** As `Boolean</api/data_types/boolean>`

If `True</api/language/true>`, applies the underline style to the control's caption and/or its text content if any.

<div id="listbox.visible">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Visible

**Visible** As `Boolean</api/data_types/boolean>`

Determines whether the control is visible when its owning window is opened. The default is `True</api/language/true>`: the control is visible.

The following code in the DisclosureTriangle Action event handler displays or hides a <span class="title-ref">ListBox</span> on the window:

``` xojo
ListBox1.Value = Me.Visible
```

<div id="listbox.width">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Width

**Width** As `Integer</api/data_types/integer>`

The width (in points) of the control.

The following example resizes the control:

``` xojo
Me.Width = 200
```

<div id="listbox.window">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Window

**Window** As `Window</api/deprecated/window>`

The control's parent window.

This property is read-only.

This code gets the parent window's Title property.

``` xojo
TextField1.Text = Me.Window.Title
```

## Method descriptions

<div id="listbox.acceptfiledrop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AcceptFileDrop

**AcceptFileDrop**(FileType As `String</api/data_types/string>`)

Permits documents of type *FileType* to be dropped on the control. *FileType* must be a file type that you defined in via the `FileType</api/files/filetype>` class or the File Type Sets Editor.

This code in the Open event of an `ImageWell</api/deprecated/imagewell>` makes it possible for the user to drop either a picture or a file that is a jpeg image. The File Type Sets editor was used to define the “image/jpeg” file type. It is one of the “Common File Types” that is available in the editor.

``` xojo
Me.AcceptPictureDrop
Me.AcceptFileDrop("image/jpeg")
```

To restrict file drops to just folders (and not files), you can put this code in the `DragEnter<rectcontrol.dragenter>` event:

``` xojo
If Not obj.FolderItem.IsFolder Then Return True
```

<div id="listbox.acceptpicturedrop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AcceptPictureDrop

**AcceptPictureDrop**

Permits pictures to be dropped on the control.

If a control should accept pictures in a drag and drop, then AcceptPictureDrop needs to be called prior to the drop. Typically, it is in the Open event of the control itself. For example, the line:

``` xojo
Me.AcceptPictureDrop
```

in the Open event of the control that will receive the dragged pictures is needed. When the picture is dropped, the `DropObject<rectcontrol.dropobject>` event is called and this is where you will put your code to handle the drop.

Canvas.Open:

``` xojo
Me.AcceptPictureDrop
```

Canvas.DropObject:

``` xojo
If obj.PictureAvailable Then
  Me.Backdrop = obj.Picture
End If
```

<div id="listbox.acceptrawdatadrop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AcceptRawDataDrop

**AcceptRawDataDrop**(Type As `String</api/data_types/string>`)

Permits data (of the Type specified) to be dropped on the control.

The following specfies a generic file type defined in the File Type Sets editor.

``` xojo
Me.AcceptRawDataDrop("????")
```

<div id="listbox.accepttextdrop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AcceptTextDrop

**AcceptTextDrop**

Permits text to be dropped on the control.

This line in the Open event of a control that can accept dragged text.

``` xojo
Me.AcceptTextDrop
```

<div id="listbox.addallrows">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AddAllRows

**AddAllRows**(items() As `String</api/data_types/string>`)

Creates a new row for every value in the items array.

<div id="listbox.addexpandablerow">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AddExpandableRow

**AddExpandableRow**(text As `String</api/data_types/string>`)

Appends *text* in a new row to the end of the list and adds disclosure triangle only if the AllowExpandableRows property is set to `True</api/language/true>`.

For multi-column ListBoxes, *Item* is always assigned to column zero. In the case of hierarchical ListBoxes, AddExpandableRow appends *Item* to the subitems of the expanded row when called in the ExpandRow event.

The following example adds creates a hierarchical <span class="title-ref">ListBox</span>. Note that AddExpandableRow must be called to create the hierarchical relationship.

``` xojo
Var s1, sub1 As String
Me.ColumnWidths = "150,0"
s1 = "Michigan,Ohio,Minnesota"
sub1 = "Grand Blanc,Bad Axe,Flint,Benton Harbor,"_
+ "Detroit;Cleveland,Columbus,Akron,Pleasantville;St. Paul,Frostbite Falls"
For i As Integer = 1 To s1.Split(",").Count
  If NthField(sub1, ";", i) <> "" Then
    Me.AddExpandableRow("")
    Me.CellValueAt(i - 1, 1) = NthField(sub1, ";", i)
  End If
  Me.CellValueAt(i - 1, 0) = NthField(s1, ",", i)
Next
Me.ColumnCount = 1
```

<div id="listbox.addexpandablerowat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AddExpandableRowAt

**AddExpandableRowAt**(index As `Integer</api/data_types/integer>`, text As `String</api/data_types/string>`)

Creates a new expandable row at *row* (zero-based), moving the existing rows down. The *text* is always assigned to column zero. The optional parameter *indent* specifies the amount of indentation of the row in a <span class="title-ref">ListBox</span> where `AllowExpandableRows<listbox.allowexpandablerows>` (sometimes called a *hierarchical* <span class="title-ref">ListBox</span>) is `True</api/language/true>`. The default is zero. It has no effect on a ListBoxe where `AllowExpandableRows<listbox.allowexpandablerows>` is `False</api/language/false>`.

The following example in a `PushButton</api/deprecated/pushbutton>` adds a row to the <span class="title-ref">ListBox</span> with expandable rows that is used for the example in `AddExpandableRow<listbox.addexpandablerow>`. It adds a new state to the list of cities and states.

``` xojo
Listbox1.AddExpandableRowAt(1, "New Hampshire")
```

<div id="listbox.addrow">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AddRow

**AddRow**(`ParamArray</api/language/paramarray>` Item As `String</api/data_types/string>`)

Appends a new blank row to the end of the list.

Adding the string "October" to a new row in a <span class="title-ref">ListBox</span> named Listbox1:

``` xojo
ListBox1.AddRow("October")
```

The following line adds a row of months to a <span class="title-ref">ListBox</span> that has four columns:

``` xojo
Listbox1.AddRow("Sept", "Oct", "Nov", "Dec")
```

The following line adds a row of months to a <span class="title-ref">ListBox</span> that has four columns using an array:

``` xojo
Var months() As String = Array("Sept", "Oct", "Nov", "Dec")
ListBox1.AddRow(months)
```

The following adds a blank row then sets values for column 3:

``` xojo
ListBox1.AddRow
ListBox1.CellValueAt(ListBox1.LastAddedRowIndex, 2) = "Col 3"
```

<div id="listbox.addrowat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.AddRowAt

**AddRowAt**(RowNumber As `Integer</api/data_types/integer>`, Item As `String</api/data_types/string>`, \[Indent As `Integer</api/data_types/integer>`\])

Creates a new row at *row* (zero-based), moving the existing rows below *row* down. For multicolumn ListBoxes, *text* is always assigned to column zero. The optional parameter *indent* specifies the amount of indentation of the row in hierarchical ListBoxes. The default is zero. It has no effect on non-hierarchical ListBoxes.

The following example inserts a row in the <span class="title-ref">ListBox</span>. The code is in a `PushButton</api/deprecated/pushbutton>`.

``` xojo
Listbox1.AddRowAt(1, "Steven")
```

<div id="listbox.cellbold">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellBold

**CellBold**(RowNumber As `Integer</api/data_types/integer>`, ColumnNumber As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

Used to add or remove the bold style from the text of the specified cell. Note that *row* and *column* are zero-based.

Assign `True</api/language/true>` to add the bold style and `False</api/language/false>` to remove the bold style. For example:

``` xojo
ListBox1.CellBold(1, 1) = True
```

<div id="listbox.cellcheckboxstateat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellCheckBoxStateAt

**CellCheckBoxStateAt**(Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`) As `CheckBox<checkbox.visualstates>`

Used to get or set the state of the cell with the coordinates of *row*, *column* (zero-based). This assumes that the passed cell is a CheckBox cell. Use the CellType property to set a cell to a CheckBox cell. `CheckBox<checkbox.visualstates>` is an `Enum</api/data_types/enumeration>` of the `CheckBox</api/deprecated/checkbox>` class.

The CellCheckBoxStateAt method enables you to get or set the value of a tri-state Checkbox cell. Any cell of type TypeCheckbox box can store one of three values: Checked, Unchecked, and Indeterminate.

To set up a cell as TypeCheckbox, use code such as this in the Open event:

``` xojo
Me.CellTypeAt(1, 0) = ListBox.CellTypes.CheckBox
```

To change the state of the cell, use the `VisualStates<checkbox.visualstates>` enum of the `CheckBox</api/deprecated/checkbox>` control:

``` xojo
ListBox1.CellCheckBoxStateAt(1, 0) = Checkbox.VisualStates.Indeterminate
```

<div id="listbox.cellitalic">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellItalic

**CellItalic**(RowNumber As `Integer</api/data_types/integer>`, ColumnNumber As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

Used to add or remove the italic style from the text of the specified cell. *row* and *column* are zero-based.

This example assigns `True</api/language/true>` to apply the italic style.

``` xojo
ListBox1.CellItalic(1, 1) = True
```

<div id="listbox.celltagat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellTagAt

**CellTagAt**(Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`) As `Variant</api/data_types/variant>`

Gets or sets a "hidden" identifier associated with the cell identified by its parameters. *Row* and *Column* are zero-based.

This example sets a tag for a cell.

``` xojo
Me.CellTagAt(1, 4) = "My Cell Tag"
```

This example displays the tag for a cell:

``` xojo
MessageBox(Me.CellTagAt(1, 4))
```

<div id="listbox.celltooltipat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellToolTipAt

**CellToolTipAt**(RowNumber As `Integer</api/data_types/integer>`, ColumnNumber As `Integer</api/data_types/integer>`) As `String</api/data_types/string>`

Used to set or get the help tag (i.e. tooltip) for a <span class="title-ref">ListBox</span> cell. *row* and *column* are zero-based.

The following adds a tip to cell 0,0. The tip is visible when the user moves the pointer over the cell.

``` xojo
Listbox1.CellToolTipAt(0, 0) = "Enter your full name."
```

<div id="listbox.cellunderline">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellUnderline

**CellUnderline**(RowNumber As `Integer</api/data_types/integer>`, ColumnNumber As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

Used to add or remove the underline style from the text of the specified cell. *row* and *column* are zero-based.

Assign `True</api/language/true>` to add the underline style and `False</api/language/false>` to remove the underline style. For example:

``` xojo
ListBox1.CellUnderline(1, 1) = True
```

<div id="listbox.cellvalueat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellValueAt

**CellValueAt**

Used to set the text of the cell based on the row and column numbers passed.

*row* and *column* are zero-based. The top-left cell is 0,0. The class constants AllColumns and AllRows can be used to specify that you wish to get or set all the values columns or rows. For example, the following specifies all columns in the last row added using AddRow or AddRowAt:

``` xojo
Me.CellValueAt(Me.LastAddedRowIndex, ListBox.AllColumns)
```

If you set this equal to a tab-delimited string, you can update the row with one line of code.

This example copies all cells from one <span class="title-ref">ListBox</span> into another:

``` xojo
ListBox2.CellValueAt(ListBox.AllRows, ListBox.AllColumns) = ListBox1.CellValueAt(ListBox.AllRows, ListBox.AllColumns)
```

The destination <span class="title-ref">ListBox</span> will have the same number of rows and columns as the source. Headers, CellTags, RowTags and ColumnTags are not copied.

In this example, the following code populates a two-column <span class="title-ref">ListBox</span> with the names of the controls in the window and their indexes.

``` xojo
Var i As Integer
For i = 0 To Self.ControlCount - 1 ' number of controls in window
  ListBox1.AddRow(Str(i)) ' first column
  ListBox1.CellValueAt(Listbox1.LastAddedRowIndex, 1) = Control(i).Name ' second column
Next
```

<div id="listbox.close_method">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Close

**Close**

Closes a control.

Closing a control permanently removes the control from memory, making it impossible to access. You can close both non-indexed controls and indexed controls. When you close an indexed control, the indexes for the remaining controls will shift downward so that the indexes start with zero and are consecutive.

The following code closes the control. When this is executed from a visible control, the control disappears from the window.

``` xojo
Me.Close
```

<div id="listbox.columnfromxy">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ColumnFromXY

**ColumnFromXY**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`) As `Integer</api/data_types/integer>`

Returns the column index from the passed mouse x, y pixel coordinates.

The parameters *X* and *Y* are relative to the top, left corner of the <span class="title-ref">ListBox</span>. If you use `System<system.mousex>` or `System<system.mousey>` to get the mouse coordinates to use with this method, you'll need to take into account that those System values are relative to the top-left corner of the entire screen.

This code in the DoubleClick event of a <span class="title-ref">ListBox</span> obtains the indexes of the cell that was double-clicked:

``` xojo
Var xValue As Integer
xValue = System.MouseX - Me.Left - Self.Left ' Calculate current mouse position relative to top left of ListBox

Var yValue As Integer
yValue = System.MouseY - Me.Top - Self.Top ' Calculate current mouse position relative to top of ListBox.

Var row, column As Integer
row = Me.RowFromXY(xValue, yValue)
column=Me.ColumnFromXY(xValue, yValue)

MessageBox("You double-clicked in cell " + row.ToString + ", " + column.ToString)
```

If you use the <span class="title-ref">ListBox</span> on a ContainerControl, then you need to also take into account the Container size:

``` xojo
Var xValue As Integer
xValue = System.MouseX - Me.Left - Self.Left - Me.TrueWindow.Left ' Calculate current mouse position relative to top left of ListBox

Var yValue As Integer
yValue = System.MouseY - Me.Top - Self.Top - Me.TrueWindow.Top ' Calculate current mouse position relative to top of ListBox.

Var row, column As Integer
row = Me.RowFromXY(xValue, yValue)
column=Me.ColumnFromXY(xValue, yValue)

MessageBox("You double-clicked in cell " + row.ToString + ", " + column.ToString)
```

<div id="listbox.columnsorttypeat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ColumnSortTypeAt

**ColumnSortTypeAt**(Column As `Integer</api/data_types/integer>`) As `ListBox<listbox.sorttypes>`

{

The default is Sortable. Sortable means that the column can be clicked on and will display mouse over events. If the column is NotSortable, then the header cannot be clicked on and will not display mouse over events. Setting *Column* to <span class="title-ref">ListBox</span>.AllColumns affects the header type of all columns.

The following code in the Open event of the <span class="title-ref">ListBox</span> sets the first two columns as sortable and the third column as non-sortable.

``` xojo
Me.ColumnSortTypeAt(0) = ListBox.SortTypes.Sortable
Me.ColumnSortTypeAt(1) = ListBox.SortTypes.Sortable
Me.ColumnSortTypeAt(2) = ListBox.SortTypes.NotSortable
```

<div id="listbox.columntagat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ColumnTagAt

**ColumnTagAt**(Column As `Integer</api/data_types/integer>`) As `Variant</api/data_types/variant>`

Gets and sets the ColumnTag for each column. Column is zero-based. ColumnTagAt can be viewed in the Debugger.

``` xojo
Me.ColumnTagAt(4) = "Enter your birthdate."
```

<div id="listbox.drawinto">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.DrawInto

**DrawInto**(g As `Graphics</api/graphics/graphics>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`)

Draws the contents of the RectControl into the specified `Graphics</api/graphics/graphics>` context. The parameters *x* and *y* are the coordinates of the top, left corner.

This method does not work with `HTMLViewer</api/deprecated/htmlviewer>` and `OpenGLSurface</api/deprecated/openglsurface>`.

This example draws the current control into the Graphics of a Picture and then displays it as the Backdrop of a Canvas:

``` xojo
Var p As New Picture(Me.Width, Me.Height)
Me.DrawInto(p.Graphics, 0, 0)
Canvas1.Backdrop = p
```

<div id="listbox.editcellat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.EditCellAt

**EditCellAt**(Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`)

Scrolls the *row*, *column* cell into view (if necessary) and temporarily makes the cell editable. *row* and *column* are zero-based. It sets the focus within the <span class="title-ref">ListBox</span> to the *row*, *column* cell and selects its contents, if any. The editable cell has a focus ring around it.

Use the `CellTypeAt<listbox.celltypeat>` or `ColumnTypeAt<listbox.columntypeat>` properties to change a cell or column to “inline editable” when you want the user to be able to edit the contents of the <span class="title-ref">ListBox</span>. Then call the EditCellAt method for each cell. This gives the editable cell the focus and selects the current text of the cell, if any. Typing replaces the cell's contents. When the user presses Tab or Return or clicks in another cell, the cell loses the focus and the contents of the cell are saved (this also calls the `CellAction<listbox.cellaction>` event handler).

When a cell is editable, the `ActiveTextControl<listbox.activetextcontrol>` property is the `TextEdit</api/deprecated/textedit>` that contains the contents of that cell. This may be a `TextField</api/deprecated/textfield>` or a `TextArea</api/deprecated/textarea>` depending on the specified column type. You can use this property to set or get the text of the <span class="title-ref">ListBox</span> cell, set the selection, or change other properties of the <span class="title-ref">ListBox</span>'s TextField or TextArea.

The following code in the CellClick event makes the cell the user pressed on editable. The parameters *row* and *column* are passed to the function.

``` xojo
Me.CellTypeAt(row, column) = Listbox.CellTypes.TextField
Me.EditCellAt(row, column)
```

This code marks an entire column as editable:

``` xojo
ListBox1.ColumnTypeAt(3) = ListBox.CellTypes.TextArea
```

In the `CellClick<listbox.cellclick>` event handler, you can then check if the column was pressed and then enable editing:

``` xojo
If column = 3 Then
  Me.EditCellAt(row, column)
End If
```

<div id="listbox.expandablerowat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ExpandableRowAt

**ExpandableRowAt**(row As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

For hierarchical ListBoxes, is used to get or set whether the row should be displayed as expandable.

``` xojo
Me.AddExpandableRow("Players")
Me.ExpandableRowAt(Me.LastAddedRowIndex) = False ' Disable expandable indicator
```

<div id="listbox.headerat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.HeaderAt

**HeaderAt** As `String</api/data_types/string>`

Returns the header for the column whose index is passed.

If you assign values to both HeaderAt and InitialValue, the first row of InitialValue is interpreted as the first row of data; otherwise, it is used as the header and the second row of InitialValue is used as the first row of data.

You can set the headers in a multi-column <span class="title-ref">ListBox</span> by assigning to HeaderAt(<span class="title-ref">ListBox</span>.AllColumns) the text of the headings separated by the tab character, e.g.,

``` xojo
Me.HeaderAt(ListBox.AllColumns) = "FirstName" + Chr(9) + "LastName"
```

You must use a space if you want an empty header; empty strings will use the default header.

``` xojo
ListBox1.HeaderAt(ListBox.AllColumns) = "" ' sets all headers of ListBox1 to their defaults.
ListBox1.HeaderAt(5) = "" ' sets column 5's header to its default heading
ListBox1.HeaderAt(5) = " " ' sets column 5's header to empty.
```

This example populates a three-column <span class="title-ref">ListBox</span> with headers:

``` xojo
ListBox1.HasHeader = True
ListBox1.HeaderAt(0) = "ID"
ListBox1.HeaderAt(1) = "JobTitle"
ListBox1.HeaderAt(2) = "Name"
```

<div id="listbox.invalidate">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Invalidate

**Invalidate**(\[EraseBackground As `Boolean</api/data_types/boolean>`\])

Similar to RefreshRect, but causes the specified region of the RectControl to be marked dirty and to be redrawn when the window contents need to be redrawn. The region to be redrawn is specified by the *X*, *Y*, *Width*, and *Height* parameters. This form of Invalidate was formerly called InvalidateRect.

The following code refreshes the control. EraseBackground defaults to `True</api/language/true>`.

``` xojo
Me.Invalidate(False)
```

<div id="listbox.invalidatecell">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.InvalidateCell

**InvalidateCell**(Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`)

Redraws the specified cell "from scratch" rather than using the data in the internal buffer.

*row* and *column* are zero-based. If you pass a -1 as the *row* or *column* parameter, it will redraw the specified entire row or column, i.e., Invalidate(2, -1) redraws row number 2. The CellBackgroundPaint and CellTextPaint events execute when InvalidateCell is called.

InvalidateCell should be necessary only if you are using a custom storage mechanism for your <span class="title-ref">ListBox</span> data. If the contents of the <span class="title-ref">ListBox</span> are stored in the <span class="title-ref">ListBox</span> cells, the <span class="title-ref">ListBox</span> will update automatically as needed.

This method doesn't have a high overhead if used unnecessarily since nothing will happen if the specified cell is not visible.

The following example redraws the specified cell.

``` xojo
Listbox1.InvalidateCell(1, 0)
```

<div id="listbox.pressheader">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.PressHeader

**PressHeader**(Column As `Integer</api/data_types/integer>`)

Causes the specified <span class="title-ref">ListBox</span> header to be pressed at column *v* (zero-based), causing a HeaderPressed event to occur. Calling this method does not update the sort direction.

This example presses the first column.

``` xojo
Listbox1.PressHeader(0)
```

<div id="listbox.refresh">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Refresh

**Refresh**(eraseBackground As `Boolean</api/data_types/boolean>`)

Repaints the portion specified of the contents of the control immediately.

Calling this frequently can cause the code executing to slow down. It is often preferable to call `RectControl<rectcontrol.invalidate>` instead.

Refresh the entire area:

``` xojo
Me.Refresh(False)
```

Refresh a portion of the area:

``` xojo
Me.Refresh(100, 150, 200, 300)
```

<div id="listbox.removeallrows">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.RemoveAllRows

**RemoveAllRows**

Removes all rows in the <span class="title-ref">ListBox</span>, including any initial values that were specified in the IDE.

This example removes all the rows in ListBox1.

``` xojo
Listbox1.RemoveAllRows
```

<div id="listbox.removerowat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.RemoveRowAt

**RemoveRowAt**(RowNumber As `Integer</api/data_types/integer>`)

Removes the specified row at *index* (zero-based).

This example removes the second row.

``` xojo
Listbox1.RemoveRowAt(1)
```

<div id="listbox.rowdepthat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.RowDepthAt

**RowDepthAt**(row As `Integer</api/data_types/integer>`) As `Integer</api/data_types/integer>`

For hierarchical ListBoxes, this is the depth of the specified row in the hierarchy. A top-level row has RowDepth = 0.

Get depth of selected row:

``` xojo
Var row As Integer = ListBox1.RowCount
Var depth As Integer = ListBox1.RowDepthAt(row)
```

<div id="listbox.rowexpandedat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.RowExpandedAt

**RowExpandedAt**(RowNumber As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

Used to get or set the expanded state of the row passed.

The row must have been added with the AddExpandableRow method.

This example expands the first row of ListBox1 (if it is collapsed) or collapses it (if it was expanded). The row must have been added with the AddExpandableRow method:

``` xojo
ListBox1.RowExpandedAt(1) = Not ListBox1.RowExpandedAt(1)
```

<div id="listbox.rowfromxy">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.RowFromXY

**RowFromXY**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`) As `Integer</api/data_types/integer>`

Returns the row index from the passed mouse x, y pixel coordinates.

The parameters *X* and *Y* are relative to the top, left corner of the <span class="title-ref">ListBox</span>. If you use `System<system.mousex>` or `System<system.mousey>` to get the mouse coordinates to use with this method, you'll need to take into account that those System values are relative to the top-left corner of the entire screen.

This code in the DoubleClick event of a <span class="title-ref">ListBox</span> added to a Window obtains the indexes of the cell that was double-clicked:

``` xojo
Var xValue As Integer
xValue = System.MouseX - Me.Left - Self.Left ' Calculate current mouse position relative to top left of ListBox

Var yValue As Integer
yValue = System.MouseY - Me.Top - Self.Top ' Calculate current mouse position relative to top of ListBox.

Var row, column As Integer
row = Me.RowFromXY(xValue, yValue)
column=Me.ColumnFromXY(xValue, yValue)

MessageBox("You double-clicked in cell " + row.ToString + ", " + column.ToString)
```

If the <span class="title-ref">ListBox</span> code is not on the window (perhaps it is in a subclass or ContainerControl), then you need to be sure to calculate the correct offsets. This code would be used for a <span class="title-ref">ListBox</span> on a ContainerControl:

``` xojo
Var xValue As Integer
xValue = System.MouseX - Me.Left - Self.Left - Me.TrueWindow.Left ' Calculate current mouse position relative to top left of ListBox

Var yValue As Integer
yValue = System.MouseY - Me.Top - Self.Top - Me.TrueWindow.Top ' Calculate current mouse position relative to top of ListBox.

Var row, column As Integer
row = Me.RowFromXY(xValue, yValue)
column=Me.ColumnFromXY(xValue, yValue)

MessageBox("You double-clicked in cell " + row.ToString + ", " + column.ToString)
```

<div id="listbox.rowimageat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.RowImageAt

**RowImageAt**(RowNumber As `Integer</api/data_types/integer>`) As `Picture</api/graphics/picture>`

Adds the image/picture assigned to the passed row *index* (zero-based).

The <span class="title-ref">ListBox</span> row does not resize to accommodate the `Picture</api/graphics/picture>`. If your picture does not fit via RowImageAt, use CellTextPaint or CellBackgroundPaint to draw the picture yourself.

The following example draws a picture in the first cell. The picture has been added to the project.

``` xojo
Listbox1.RowImageAt(0) = UserPhotoImage
```

<div id="listbox.rows">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Rows

**Rows** As `ListBoxRow</api/deprecated/listboxrow>`

Allows you to iterate through all the rows in a <span class="title-ref">ListBox</span>.

In this example, the Tag of each row is examined and if it's found to be "Taxable", the ComputeTaxes method is called and passed the value of the row.

``` xojo
For Each row As ListBoxRow In ListBox1.Rows
  If row.Tag = "Taxable" then ComputeTaxes(row.ColumnValueAt(0))
Next
```

<div id="listbox.rowtagat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.RowTagAt

**RowTagAt**(Row As `Integer</api/data_types/integer>`) As `Variant</api/data_types/variant>`

Gets and sets the RowTag for the *row* (zero-based).

To set the tag:

``` xojo
ListBox1.RowTagAt(row) = "MyTag"
```

To get the tag:

``` xojo
myTag = ListBox1.RowTagAt(row)
```

<div id="listbox.setfocus">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.SetFocus

**SetFocus**

If applicable, sets the focus to the RectControl. KeyDown events are directed to the control.

If the control cannot get the focus on the platform on which the application is running, SetFocus does nothing. The SetFocus method of the `Window</api/deprecated/window>` class or the `ClearFocus</api/user_interface/desktop/clearfocus>` method can be used to remove the focus from the control that currently has the focus, leaving no control with the focus.

On the Mac you need Full Keyboard Access turned on in System Preferences (Keyboard-\>Shortcuts) in order to manually set focus to non-text controls.

The following example sets the focus to TextField1. If another control has the focus when this line is executed, then the user sees that TextField1 gets the focus.

``` xojo
TextField1.SetFocus
```

<div id="listbox.sort">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Sort

**Sort**

Sorts the rows based on the current values of the `SortingColumn<listbox.sortingcolumn>` and `ColumnSortDirectionAt<listbox.columnsortdirectionat>` properties.

When `AllowExpandableRows<listbox.allowexpandablerows>` is `True</api/language/true>` and a <span class="title-ref">ListBox</span> is sorted, the rows are sorted at all levels of the hierarchy, not just the base level.

To ensure the sort indicator displays after sorting you can force the header to refresh like this:

``` xojo
Listbox1.HasHeader = True
```

The following code sorts a <span class="title-ref">ListBox</span> in descending order on the first column.

``` xojo
' first column, descending order
ListBox1.ColumnSortDirectionAt(0) = ListBox.SortDirections.Descending
ListBox1.SortingColumn = 0 ' first column is the sort column
ListBox1.Sort
```

## Event descriptions

<div id="listbox.cellaction">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellAction

**CellAction**(Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`)

If a cell is editable, a CellAction event occurs when the user finishes editing a cell. *Row* and *Column* are zero-based.

“Finishing editing” is defined as exiting the cell after clicking in it. Tabbing out of the editable cell or clicking another cell triggers this event. Clicking a checkbox in a checkbox cell also qualifies as "finishing editing".

The user doesn't necessarily have to change the contents.

This code will display changes made to an editable cell when the user finishes editing (by either pressing return or switching to a different cell):

``` xojo
If column = 2 Then ' Is this the editable column?
  MessageBox("You entered: " + Me.Cell(row, column))
End If
```

This event handler is also called when the user clicks a CheckBox cell:

``` xojo
If column = 3 Then ' Is this the CheckBox column?
  If Me.CellCheckBoxAt(row, column) Then
    MessageBox("You checked the checkbox in row " + row.ToString)
  Else
    MessageBox("You unchecked the checkbox in row " + row.ToString)
  End If
End If
```

<div id="listbox.cellbackgroundpaint">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellBackgroundPaint

**CellBackgroundPaint**(g As `Graphics</api/graphics/graphics>`, Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

The parameter *g* is a `Graphics</api/graphics/graphics>` object that corresponds to the content area of the cell identified by the parameters *Row*, *Column*. 0,0 is the upper left of the cell. Returns a `Boolean</api/data_types/boolean>`. `True</api/language/true>` means the user has handled the background paint and no other processing is to be done with the background. In this case the user is responsible for all highlighting. `False</api/language/false>` means the user wants the default background; this will overwrite your drawing on the row that needs to be highlighted as the row or column will be highlighted as appropriate (according to the platform and the hierarchical style).

This code can be used to do alternate row highlighting:

``` xojo
If row Mod 2 = 0 Then
  g.DrawingColor = &cf3f6fA
  g.FillRectangle(0, 0, g.Width, g.Height)
End If
```

This example paints the cell background red if the CellTag contains the string "Red":

``` xojo
If Me.CellTagAt(row, column ) = "Red" Then
  g.DrawingColor =Color.RGB(255, 0, 0)
  g.FillRectangle(0, 0, g.Width, g.Height)
End If
```

<div id="listbox.cellclick">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellClick

**CellClick**(Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`, X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

The user has clicked on the *Row*, *Column* cell. *Row* and *Column* are zero-based. The parameters *X* and *Y* are the x and y coordinates of the mouse click relative to the top-left corner of the cell that was clicked. *X* and *Y* are on the same scale of reference as the coordinates used by the `Graphics</api/graphics/graphics>` property of the CellBackgroundPaint event.

To give the user the ability to edit the cell, change the CellType to Editable (<span class="title-ref">ListBox</span>.TypeEditable) and then call the EditCell method. The user will then get a focusing ring around the cell and the current text will become editable. When the user tabs out of the cell, the changes will be saved. You will get the CellAction event.

CellClick returns a `Boolean</api/data_types/boolean>`. Returning `True</api/language/true>` means that the event will not be processed further (i.e., editable cells won't be editable and <span class="title-ref">ListBox</span> selection won't change).

This code makes a cell editable when it is clicked:

``` xojo
If column = 2 Then ' Is this the editable column?
  Me.ColumnTypeAt(column) = ListBox.CellTypes.TextField
  Me.CellEditTextAt(row, column)

  Return True
End If
```

<div id="listbox.cellgotfocus">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellGotFocus

**CellGotFocus**(Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`)

The user has selected an editable cell of a <span class="title-ref">ListBox</span>. *Row* and *Column* are zero-based. The *Row* and *Column* parameters indicate which cell just got the focus.

<div id="listbox.cellkeydown">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellKeyDown

**CellKeyDown**(Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`, Key As `String</api/data_types/string>`) As `Boolean</api/data_types/boolean>`

The user has pressed a key while a cell in the <span class="title-ref">ListBox</span> is being edited. *Row* and *Column* are zero-based.

This cell is identified by the *Row* and *Column* parameters. *Key* is the key that the user pressed.

CellKeyDown returns a `Boolean</api/data_types/boolean>`. Returning `True</api/language/true>` prevents the text from changing automatically and prevents the CellTextChange event from firing.

<div id="listbox.celllostfocus">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellLostFocus

**CellLostFocus**(Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`)

The *Row*, *Column* cell has just lost the focus. *Row* and *Column* are zero-based. The user could have clicked on another cell or pressed Tab, Return, or Escape.

<div id="listbox.celltextchange">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellTextChange

**CellTextChange**(Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`)

Occurs after the KeyDown event if the KeyDown event returns `False</api/language/false>`.

The event is passed the *Row* and *Column* of the cell being edited.

<div id="listbox.celltextpaint">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CellTextPaint

**CellTextPaint**(g As `Graphics</api/graphics/graphics>`, Row As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

The parameter g is a `Graphics</api/graphics/graphics>` object that corresponds to the text drawing area of the cell identified by *Row*, *Column*. *Row* and *Column* are zero-based. This does not necessarily correspond to the entire cell content area, for example, if you use a row picture in the cell.

In order for this event handler to be called, the cell itself must have been given a value, even if it is blank.

The parameters *x* and *y* are the coordinates of the suggested ideal location to draw text based on the current value of ColumnAlignment or CellAlignment, as well as the cell's font, font size, and font style.

The drawing order of the cell is as follows, with the background first:

\* Background *Disclosure Triangle/Treebox*Checkbox *RowPicture*Text \*Border

Although the border is painted last, it isn't advisable to change the state of the border in the CellTextPaint event since the area is determined by the size of the border before the cell is painted. It could leave unpainted areas or possibly cover up some of the painting you have done.

Returning `True</api/language/true>` means the user has handled the text paint and no other processing is to be done with the text. In this case, the user is responsible for text highlighting. Text highlighting is currently only done for the hierarchical <span class="title-ref">ListBox</span> style. Returning `False</api/language/false>` means the user wants the default text drawing. In this case, the text will be highlighted as appropriate (according to platform) for you automatically.

This code draws a small triangle on the right side of the cell (the code is using column 3 as the cell to draw into):

``` xojo
Select Case column
Case 3 ' Is this the column to draw into?
  ' Draw an arrow to indicate that clicking this field will
  ' display a menu
  g.DrawingColor = &c000000

  ' Points for a triangle on the right side of the cell
  Var points(6) As Integer
  points(1) = g.Width - 10
  points(2) = 1
  points(3) = g.Width
  points(4) = 1
  points(5) = g.Width - 5
  points(6) = 10

  g.FillPolygon(points)

  Return True
End Select
```

Now you can display a menu when the user clicks in the cell by putting code in the MouseDown and MouseUp event handlers.

This goes in MouseDown to allow the MouseUp event handler to be called:

``` xojo
If Me.ColumnFromXY(x, y) = 3 Then
  Return True
End If
```

This code in MouseUp displays a simple menu:

``` xojo
' Display menu if clicked in PopupMenu column
Var row As Integer = Me.RowFromXY(x, y)
Var col As Integer = Me.ColumnFromXY(x, y)

If col = 3 Then
  Me.SelectedIndex = row
  Me.Selected(row) = True

  Var base As New MenuItem
  base.AddMenu(New MenuItem("Red"))
  base.AddMenu(New MenuItem("Green"))
  base.AddMenu(New MenuItem("Blue"))
  base.AddMenu(New MenuItem("Black"))
  base.AddMenu(New MenuItem("White"))

  Var selectedMenu As MenuItem
  selectedMenu = base.PopUp

  If selectedMenu <> Nil Then
    MessageBox("You changed the color to " + selectedMenu.Value + ".")
  End If
End If
```

<div id="listbox.change">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Change

**Change**

The Change event is called when the row selection is changed by the user or by code.

The Change event handler is called when the row selection changes, not when cell contents change.

The Change event handler is called in response to the following user actions: \* When the <span class="title-ref">ListBox</span> is clicked to give it the focus \* When an empty row in the <span class="title-ref">ListBox</span> is clicked \* When a cell is clicked even if it already is selected and the column is not editable \* When a row is clicked to change the selection

If a column is editable, clicking in a cell calls the Change event but a second click to get an insertion point does not. Clicking on a header or a checkbox does not call the Change event.

Also, a programmatic change to `ListBox<listbox.selectedrowindex>` also triggers the Change event.

<div id="listbox.close_event">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Close

**Close**

The control is about to close.

<div id="listbox.collapserow">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CollapseRow

**CollapseRow**(Row As `Integer</api/data_types/integer>`)

The user has clicked on the disclosure triangle of the expanded *Row* passed or the rows expanded property was set false programmatically. *Row* is zero-based.

<div id="listbox.comparerows">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.CompareRows

**CompareRows**(Row1 As `Integer</api/data_types/integer>`, Row2 As `Integer</api/data_types/integer>`, Column As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` Result As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

The CompareRows event is used for sorting a column of a <span class="title-ref">ListBox</span> in a manner that is not provided by the default mechanism. *Row* and *Column* are zero-based. The result of the comparison is returned in the last parameter, *Result*, which is declared `Byref</api/language/byref>`. The default mechanism sorts cell values lexicographically. If you implement the event, it gets called during a <span class="title-ref">ListBox</span> sort, e.g., when a user clicks in the header area.

**Parameters**: \* Row1: Row number of one of the rows being compared. \* Row2: Row number of the other row being compared. \* Column: Number of column being sorted.

Set **Result** to: \* 0: If items in Row1 and Row2 in specified column are equal. \* -1: Contents of Row1 \< Contents of Row2. \* 1: Contents of Row1 \> Contents of Row2.

`Return</api/language/return>` `True</api/language/true>` if the returned *Result* parameter is accurate for sorting.

`Return</api/language/return>` `False</api/language/false>` if you want the <span class="title-ref">ListBox</span> to use the default lexicographic sorting of the column.

Suppose your <span class="title-ref">ListBox</span> contains a first column (numbered 0) which contains a string value. You can let the <span class="title-ref">ListBox</span> use the default lexicographic comparison for such a column. However, the second column (numbered 1) contains a numerical value that should be sorted as such. You can implement the RowCompared event as follows:

``` xojo
Function CompareRows(row1 As Integer, row2 As Integer, column As Integer, ByRef result As Integer) As Boolean
  Select Case column
  Case 0 ' This is a string column. Let the listbox manage it by returning false
    Return False

  Case 1 ' This is our numerical value column. Let's do the work ourselves
    If Val(Me.CellValueAt(row1, column )) < Val(Me.CellValueAt(row2, column)) Then
      result = -1
    ElseIf Val(Me.CellValueAt(row1, column)) > Val(Me.CellValueAt(row2, column)) Then
      result = 1
    Else
      result = 0
    End If
    Return True

  Else //some other column for which we let the listbox handle comparison
    Return False
  End Select
End Function
```

or, more simply, using the `Sign</api/math/sign>` function:

``` xojo
Function CompareRows(row1 As Integer, row2 As Integer, column As Integer, ByRef result As Integer) As Boolean
  Select Case column
  Case 0  ' This is a string column. Let the listbox manage it by returning false
    Return False

  Case 1 ' This is our numerical value column. Let's do the work ourselves
    result = Sign(Val(Me.CellValueAt(row1, column)) - Val(Me.CellValueAt( row2, column)))
    Return True

  Else //some other column for which we let the listbox handle comparison
    Return False
  End Select
End Function
```

To sort a column containing checkboxes use

``` xojo
Function CompareRows(row1 As Integer, row2 As Integer, column As Integer, ByRef result As Integer) As Boolean
  ' Column 0 contains checkboxes.  
  ' We want to sort it by checkbox value, with unchecked rows before checked rows.

  Select Case column
  Case 0 ' column 0 contains our checkboxes
     If Me.CellCheckBoxValueAt(row1, column) XOr Me.CellCheckBoxValueAt(row2, column) Then
      ' CellCheckBox values are unequal.  If row1 is true, then row2 must be true and vice versa.
      If Me.CellCheckBoxValueAt(row1, column) Then
        ' row1 < row2
        result = 1
      Else
        ' row1 < row2
        result = -1
      End If
    Else
      ' CellCheckBox values are equal, so row1 = row2.
      result = 0
    End If
    Return True

  Else
    ' let the listbox do default comparison
    Return False
  End Select
End Function
```

<div id="listbox.constructcontextualmenu">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ConstructContextualMenu

**ConstructContextualMenu**(Base As `MenuItem</api/deprecated/menuitem>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

This event is called when it is appropriate to display a contextual menu for the control.

This event handler is the recommended way to handle contextual menus because this event figures out whether the user has requested the contextual menu, regardless of how they did it. Depending on platform, it might be in the MouseUp or MouseDown event and it might be a right+click or by pressing the contextual menu key on the keyboard, for example.

*Base* is analogous to the menu bar for the contextual menu. Any items you add to *Base* will be shown as menu items. If you return `False</api/language/false>`, the event is passed up the parent hierarchy.

If you return `True</api/language/true>`, the contextual menu is displayed. The parameters *x* and *y* are the mouse locations. If the event was fired because of a non-mouse event, then *x* and *y* are both set to -1. See the example of a contextual menu in the following section.

The following ConstructContextualMenu event handler builds a menu with three menu items plus a submenu with three additional menu items.

``` xojo
' Add some items
base.AddMenu(New MenuItem("Test 1"))
base.AddMenu(New MenuItem("Test 2"))
base.AddMenu(New MenuItem("Test 3"))

' Add a Separator
base.AddMenu(New MenuItem(MenuItem.TextSeparator))

' Add a sub menu
Var submenu As New MenuItem("SubMenu")
submenu.AddMenu(New MenuItem("SubMenu Test 1"))
submenu.AddMenu(New MenuItem("SubMenu Test 2"))
submenu.AddMenu(New MenuItem("SubMenu Test 3"))
base.AddMenu(submenu)

' Add a Separator
base.AddMenu(New MenuItem(MenuItem.TextSeparator))

Return True
```

<div id="listbox.contextualmenuaction">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ContextualMenuAction

**ContextualMenuAction**(HitItem As `MenuItem</api/deprecated/menuitem>`) As `Boolean</api/data_types/boolean>`

Fires when a contextual menuitem *hitItem* was selected but the Action event and the MenuHandler for the menuitem did not handle the menu selection.

This event gives you a chance to handle the menu selection by inspecting the menuitem's Text or Tag properties to see which item was selected. Use this in conjunction with ConstructContextualMenu if you have not specified the Action event or the Menu Handler for the items on the contextual menu. See the example of a contextual menu in the examples for the **RectControl** class.

`Return</api/language/return>` `True</api/language/true>` if this event has handled the item the user chose from the contextual menu. Returning `False</api/language/false>` will cause the control's parent to execute its ContextualMenuAction event. This can be handy if you have the same contextual menu for several controls who share the same `Parent<rectcontrol.parent>` (several on the same window for example). By returning `False</api/language/false>` you can handle them all in a single event.

This simple event handler displays the value of the selected menu item.

``` xojo
If hitItem <> Nil Then MessageBox(hitItem.Value)
Return True
```

<div id="listbox.disclosurewidgetpaint">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.DisclosureWidgetPaint

**DisclosureWidgetPaint**(g As `Graphics</api/graphics/graphics>`, row As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` x As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` y As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` width As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` height As `Integer</api/data_types/integer>`)

Invoked for hierarchical ListBoxes when the framework needs to draw the disclosure triangle for a folder row. This is invoked after CellBackgroundPaint and before CellTextPaint.

The left, top, width and height parameters: \* Default to the coordinates for drawing the built-in widget \* These coordinates are also used for hit testing to determine if a mousedown should toggle the row's expanded state. \* Are ByRef so the user can specify the location of the rectangle used for hit testing when drawing their own widget, if for instance the hit area is smaller than the drawn widget. \* Setting width or height to zero will completely hide the triangle and no hit testing will be done. \* Returning False causes the framework widget to be drawn. \* Returning True prevents the framework from drawing its own disclosure widget, signaling that the event has performed all of the necessary drawing. \* Changing the Width parameter and returning True will offset the graphic object that is provided in the following CellTextPaint event by the same offset. i.e. if the supplied Width is 10, but the code changes it to 5 the graphic object in the CellTextPaint event would be offset by 5 pixels to the left.

<div id="listbox.doubleclick">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.DoubleClick

**DoubleClick**

The user has double-clicked on a row in the <span class="title-ref">ListBox</span>.

<div id="listbox.dragenter">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.DragEnter

**DragEnter**(obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

Fires when the passed `DragItem</api/user_interface/desktop/dragitem>` enters the RectControl.

Returns a `Boolean</api/data_types/boolean>`. Return `True</api/language/true>` from this event to prevent the drop from occurring.

The Action parameter specifies the drag action. It can take the following class constants of the `DragItem</api/user_interface/desktop/dragitem>` class:

| Value | Class Constant                                                     |
|-------|--------------------------------------------------------------------|
| 0     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionDefault |
| 1     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionCopy    |
| 2     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionMove    |
| 3     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionLink    |

To restrict file drops to just folders (and not files), you can put this code in the DragEnter event:

``` xojo
If Not obj.FolderItem.IsFolder Then Return True
```

<div id="listbox.dragexit">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.DragExit

**DragExit**(obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>`)

Fires when the passed `DragItem</api/user_interface/desktop/dragitem>` exits the RectControl.

The *Obj* parameter is the item being dragged. The *Action* parameter specifies the drag action. It can take the following class constants of the `DragItem</api/user_interface/desktop/dragitem>` class:

| Value | Constant                                                           |
|-------|--------------------------------------------------------------------|
| 0     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionDefault |
| 1     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionCopy    |
| 2     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionMove    |
| 3     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionLink    |

<div id="listbox.dragover">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.DragOver

**DragOver**(x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

Fires when the `DragItem</api/user_interface/desktop/dragitem>` is over the RectControl.

The *Obj* parameter is the object being dragged. The coordinates x and y are relative to the **RectControl**. Returns a `Boolean</api/data_types/boolean>`. Return `True</api/language/true>` from this event to prevent the drop from occurring.

The *Action* parameter specifies the drag action, which is typically done by holding down a modifier key (Shift, Alt, Option, Command, etc.) while doing the drag. It can take the following class constants of the `DragItem</api/user_interface/desktop/dragitem>` class:

| Value | Constant                                                           |
|-------|--------------------------------------------------------------------|
| 0     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionDefault |
| 1     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionCopy    |
| 2     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionMove    |
| 3     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionLink    |

<div id="listbox.dragoverrow">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.DragOverRow

**DragOverRow**(x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, obj As `DragItem</api/user_interface/desktop/dragitem>`, action As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` row As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` parentRow As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` location As `ListBox<listbox.droplocations>`)

Invoked during dragging, similar to the DragOver event.

Event handlers can 'retarget' a drop by altering the row, parentRow, or location parameters.

- x: The x coordinate of the drop, relative to the left of the <span class="title-ref">ListBox</span>.
- y: The y coordinate of the drop, relative to the top of the <span class="title-ref">ListBox</span>.
- obj: The data actually being dropped.
- action: The drag action, which can be things like move or copy. Constants already exist in the DragItem class for this.
- row: The proposed target row for the drop.
- parentRow: When the <span class="title-ref">ListBox</span> is non-hierarchical, this will always be -1. When the <span class="title-ref">ListBox</span> is hierarchical, this is the row that the item is being dragged into. If the item is being dragged to the top level, parentRow will have a value of -1.
- location: Whether the drop is going between two rows, on the row itself or just on the control. Uses the <span class="title-ref">ListBox</span>.DropLocations enum.

Returning True prevents the drop from occurring and the DragOver event from firing. Otherwise the DragOver event fires.

<div id="listbox.dragreorderrows">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.DragReorderRows

**DragReorderRows**(NewPosition As `Integer</api/data_types/integer>`, ParentRow As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

This event is called when one or more rows are selected then moved in the <span class="title-ref">ListBox</span> to a new position. The `ListBox<listbox.allowrowreordering>` property must be `True</api/language/true>` in order for this event to be called.

<div id="listbox.dragrow">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.DragRow

**DragRow**(Drag As `DragItem</api/user_interface/desktop/dragitem>`, Row As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

The user is dragging a row. *Row* is zero-based.

*Drag* is the `DragItem</api/user_interface/desktop/dragitem>` object that is created automatically. Assign the values to the `DragItem</api/user_interface/desktop/dragitem>`'s properties that the user should drag. *Row* is the row of the <span class="title-ref">ListBox</span> that is being dragged. You must return `True</api/language/true>` in this event handler to allow the drag to occur.

Setting up the DragRow event handler to allow the user to drag a value from a \`ListBox\`:

``` xojo
Function DragRow(drag As DragItem, row As Integer) As Boolean
  drag.Text = ListBox1.List(row)
  Return True
End Function
```

If you want to allow multiple row selection and dragging, then you need to process all the rows in the selection. This version of the DragRow event handler illustrates this.

``` xojo
Function DragRow(drag As DragItem, row As Integer) As Boolean 
Dim nRows As Integer
Dim additionalItems As Boolean
For i As Integer = 0 To Me.RowCount - 1
  If Me.Selected(i) Then
    If Not additionalItems Then
      additionalItems = True
    Else
      drag.AddItem(0, 0, 0, 0) ' No need to specify a rect for just text
    End If
    drag.Text = Me.List(i)
  End If
Next

Return True
End Function
```

<div id="listbox.dropobject">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.DropObject

**DropObject**(Obj As `DragItem</api/user_interface/desktop/dragitem>` Action As `Integer</api/data_types/integer>`)

The item represented by *Obj* has been dropped on the control.

The *Obj* parameter is the object being dragged. The *Action* parameter specifies the drag action. It can take the following class constants of the `DragItem</api/user_interface/desktop/dragitem>` class:

{\| class="genericTable" ! width=10% Class Constant 0 \| `DragItem</api/user_interface/desktop/dragitem>`.DragActionDefault 1 \| `DragItem</api/user_interface/desktop/dragitem>`.DragActionCopy 2 \| `DragItem</api/user_interface/desktop/dragitem>`.DragActionMove 3 \| `DragItem</api/user_interface/desktop/dragitem>`.DragActionLink }

The following DropObject event handler can handle either a dropped picture or a dropped file. The type of file that it can handle needs to have been specified in a call to AcceptFileDrop prior to the drop, for example, in the Open event.

``` xojo
If Obj.PictureAvailable Then
  Me.Image = obj.Picture
ElseIf Obj.FolderItemAvailable Then
  Me.Image = Picture.Open(obj.FolderItem)
End If
```

<div id="listbox.dropobjectonrow">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.DropObjectOnRow

**DropObjectOnRow**(x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, obj As `DragItem</api/user_interface/desktop/dragitem>`, action As `Integer</api/data_types/integer>`, row As `Integer</api/data_types/integer>`, parentRow As `Integer</api/data_types/integer>`, location As `ListBox<listbox.droplocations>`)

Invoked when a drop has finished.

The row, parentRow, and `location<listbox.droplocations>` are the values previously set by the DragOverRow event handler.

The DropObject event fires after this event.

This code in the event handler shows the different values that can be passed for the Location parameter.

``` xojo
Select Case location
Case listbox.DropLocations.AfterAllRows
  MessageBox "add row after all rows"
Case listbox.DropLocations.AfterRow
  MessageBox "add row after rowindex = " + CStr(row)
Case listbox.DropLocations.OnControl
  MessageBox "drop occurred ON control"
Case listbox.DropLocations.OnRow
  MessageBox "add row to rowindex = " + CStr(row)
End Select
```

<div id="listbox.enablemenuitems">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.EnableMenuItems

**EnableMenuItems**

The control has received the focus. Menu handlers are invoked if the control has the focus.

<div id="listbox.expandrow">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.ExpandRow

**ExpandRow**(Row As `Integer</api/data_types/integer>`)

The user has clicked on the disclosure triangle, or the expanded property was set to true programmatically, for a collapsed row that was added using `AddFolder<listbox.addexpandablerow>`. *Row* is zero-based.

The rows are not persisted when the folder is later collapsed. Use the ExpandRow event handler to re-add rows as necessary.

This code adds children to the expanded row:

``` xojo
For childRow As Integer = 0 To 5
  Me.AddRow("Child " + Str(childRow) + " of row " + Me.CellValueAt(row, 0))
Next
```

<div id="listbox.gotfocus">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.GotFocus

**GotFocus**

The <span class="title-ref">ListBox</span> has received the focus and has a selection rectangle around it.

<div class="note">

<div class="title">

Note

</div>

On Macintosh, controls other than text fields and lists will accept focus only if the full keyboard access option is enabled in System Preferences/Keyboard.

</div>

<div id="listbox.headerbackgroundpaint">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.HeaderBackgroundPaint

**HeaderBackgroundPaint**(g As `Graphics</api/graphics/graphics>`, column As `Integer</api/data_types/integer>`)

Allow you to take control of drawing the background of the column headers.

Return `True</api/language/true>` from this event to make any drawing you do in the `Graphics</api/graphics/graphics>` parameter passed (*g*) take effect.

<div id="listbox.headercontentpaint">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.HeaderContentPaint

**HeaderContentPaint**(g As `Graphics</api/graphics/graphics>`, column As `Integer</api/data_types/integer>`)

Allow you to take control of drawing the content of the column headers.

Return `True</api/language/true>` from this event to make any drawing you do in the `Graphics</api/graphics/graphics>` parameter passed (*g*) take effect.

<div id="listbox.headerpressed">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.HeaderPressed

**HeaderPressed**(Column As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

Runs after a <span class="title-ref">ListBox</span> header has been clicked/pressed. The index on *Column* is zero-based. You can use this event to specify whether you want to sort the column that was pressed. If you return `True</api/language/true>`, the column is not sorted and it does not update the SortedColumn property.

<div id="listbox.keydown">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.KeyDown

**KeyDown**(Key As `String</api/data_types/string>`) As `Boolean</api/data_types/boolean>`

The user has pressed the *Key* passed while the `control</api/deprecated/rectcontrol>` has the focus.

How KeyDown works depends on the type of control.

**TextField and TextArea** Returning `True</api/language/true>` means the key is intercepted, preventing the key from actually reaching the control at all. This would be useful if you want to override the behavior of the tab key for example. Returning `False</api/language/false>` means the key reaches the control.

**All Other Controls** Returning `True</api/language/true>` prevents the KeyDown event on the parent control (usually the window) from executing. Returning `False</api/language/false>` results in the execution of the KeyDown event of the parent control.

<div id="listbox.keyup">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.KeyUp

**KeyUp**(Key As `String</api/data_types/string>`)

Fires when the passed *Key* is released in the RectControl that has the focus.

It is not guaranteed to be the same key that received the KeyDown event.

<div id="listbox.lostfocus">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.LostFocus

**LostFocus**

The <span class="title-ref">ListBox</span> has lost the focus.

<div class="note">

<div class="title">

Note

</div>

On Macintosh, controls other than text fields and lists will accept and lose focus only if the full keyboard access option is enabled in System Preferences/Keyboard.

</div>

<div id="listbox.mousedown">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.MouseDown

**MouseDown**(x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

The mouse button was pressed inside the control's region at the location passed in to *x*, *y*.

The coordinates *x* and *y* are local to the control, i.e. they represent the position of the mouse click relative to the upper-left corner or the <span class="title-ref">ListBox</span>.

`Return</api/language/return>` `True</api/language/true>` if you are going to handle the MouseDown. In such a case:

- The Action event, if any, will not execute and the state of the object will not change.
- You will receive the `MouseDrag<listbox.mousedrag>` and `MouseUp<listbox.mouseup>` events.

If you return False, the system handles the MouseDown so the `MouseDrag<listbox.mousedrag>` and `MouseUp<listbox.mouseup>` event handlers do not get called.

The MouseDown event uses the `DragItem</api/user_interface/desktop/dragitem>` constructor when the user drags the contents of the control. It is:

``` xojo
Var d As DragItem
d = New DragItem(Self, Me.Left, Me.Top, Me.Width, Me.Height)
d.Picture = Me.Image
d.Drag ' Allow the drag
```

<div id="listbox.mousedrag">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.MouseDrag

**MouseDrag**(x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`)

This event fires continuously after the mouse button was pressed inside the <span class="title-ref">ListBox</span>. Mouse location is local to the control passed in to *x*, *y*.

<div class="note">

<div class="title">

Note

</div>

This event will not occur unless you return `True</api/language/true>` in the `MouseDown<listbox.mousedown>` event first.

</div>

The parameters *x* and *y* are local coordinates, i.e. they represent the position of the mouse relative to the upper-left corner of the <span class="title-ref">ListBox</span>.

As this event is fired continuously (hundreds of time per second), it is your responsibility to determine if the mouse has really moved.

<div id="listbox.mouseenter">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.MouseEnter

**MouseEnter**

The mouse has entered the area of the control.

<div id="listbox.mouseexit">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.MouseExit

**MouseExit**

The mouse has left the area of the control.

<div id="listbox.mousemove">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.MouseMove

**MouseMove**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`)

The mouse has moved within the control to the coordinates passed. The coordinates are local to the control, not to the window.

<div id="listbox.mouseup">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.MouseUp

**MouseUp**(x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`)

The mouse button was released. Use the *x* and *y* parameters to determine if the mouse button was released within the control's boundaries.

<div class="note">

<div class="title">

Note

</div>

This event will not occur unless you return `True</api/language/true>` in the MouseDown event. The return value is ignored.

</div>

The parameters *x* and *y* are local coordinates, i.e. they represent the position of the mouse click relative to the upper-left corner or the <span class="title-ref">ListBox</span>. Mouse clicks that are released to the left or above a control are negative.

<div id="listbox.mousewheel">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.MouseWheel

**MouseWheel**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`, DeltaX As `Integer</api/data_types/integer>`, DeltaY As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

The mouse wheel has been moved.

The parameters *X* and *Y* are the mouse coordinates relative to the control that has received the event. The parameters *DeltaX* and *DeltaY* hold the number of scroll lines the wheel has been moved horizontally and vertically, as defined by the operating system. *DeltaX* is positive when the user scrolls right and negative when scrolling to the left. *DeltaY* is positive when the user scrolls down and negative when scrolling up.

Returns a `Boolean</api/data_types/boolean>`. Return `True</api/language/true>` to prevent the event from propagating further.

<div id="listbox.open">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.Open

**Open**

The control is about to be displayed. Use this event to initialize a control.

The Open event is called after the Constructor.

Be warned that initializing control property values using the Constructor instead of the Open event may result in those property values being overwritten by what is set in the Inspector. For best results, use the Open event for control initialization rather than the control Constructor.

If the control is supposed to handle drag and drop, you need to tell it which type of item it needs to be able to handle. The following example informs the control that pictures and files can be dropped on it. The type of the file it needs to support is specified via the File Types Editor.

``` xojo
Sub Open()
  Me.AcceptPictureDrop
  Me.AcceptFileDrop("JPEG")
End Sub
```

<div id="listbox.sortcolumn">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ListBox.SortColumn

**SortColumn**(Column As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

The user has clicked on the passed column header to sort that column or the Sort method was called. Column is zero-based.

`Return</api/language/return>` `True</api/language/true>` if you don't want the <span class="title-ref">ListBox</span> to be sorted.

Note that sorting is based on string comparisons. If you want to sort numbers, dates or CheckBoxes then you have to use a custom sort in the `ListBox<listbox.comparerows>` event.

If you're trying to prevent the user from sorting the column in the first place, use `ListBox<listbox.columnsortdirectionat>`.

## Notes

Items in single-column ListBoxes can be accessed using the List property. The List property is an array. Arrays are zero-based. This means that the first row of the List property of a <span class="title-ref">ListBox</span> is row number 0 (zero).

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Iterating through rows

The `Rows<listbox.rows>` method returns a `ListBoxRow</api/deprecated/listboxrow>` which allows you to easily iterate through rows. In this example, the Tag of each row is examined and if it's found to be "Taxable", the ComputeTaxes method is called and passed the value of the row.

``` xojo
For Each row As ListboxRow In Listbox1.Rows
  If row.Tag = "Taxable" Then ComputeTaxes(row.Value)
Next
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Configuring and accessing multiple columns

You can create multi-column ListBoxes by changing the ColumnCount property. The first column in a multi-column <span class="title-ref">ListBox</span> is column 0 (zero). This means that the ColumnCount property will always be one more than the number of the last column. The maximum number of columns is 256 (columns 0 through 255). You should set ColumnCount to the number of columns that you want to display. If you want to put data in an invisible column, set the column width to zero.

You can use the InitialValue property to set up the inital values of multi-column ListBoxes by separating the column values with tabs and row values with carriage returns.

The widths of columns in multi-column ListBoxes can be set by passing the widths as a list of values separated by commas to the ColumnWidths property. The widths can be passed in points or as percentages of the total width of the <span class="title-ref">ListBox</span>. If you don't pass widths for all the columns, the remaining columns will be evenly spaced over the remaining space. If too many widths are passed, the additional values are ignored. If the total of the widths passed is greater than the width of the <span class="title-ref">ListBox</span>, then the remaining columns will be truncated.

Specific cells in a multi-column <span class="title-ref">ListBox</span> can be accessed using the CellValueAt method. To populate a multi-column <span class="title-ref">ListBox</span>, first use the AddRow method to create the new row and populate the first column. Then use the CellValueAt method to add values to the other columns in the row. Use the LastAddedRowIndex property to get the index of the row you just added with AddRow.

For example, the following code populates a two-column <span class="title-ref">ListBox</span> with the names of the controls in the window and their indexes.

``` xojo
For i As Integer = 0 To Self.ControlCount - 1  ' number of controls in window
  ListBox1.AddRow(Str(i)) ' first column
  ListBox1.CellValueAt(Listbox1.LastAddedRowIndex, 1) = Control(i).Name ' second column
Next
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Determining which cell was double-clicked

The DoubleClick event fires when the user double-clicks anywhere inside a <span class="title-ref">ListBox</span>, but the indexes of the cell that was double-clicked are not passed. You can determine which cell was double-clicked with the RowFromXY and ColumnFromXY methods. They use the x,y mouse coordinates where the double-click took place and translate them into the row and column indexes of the cell that was clicked. You need to adjust for the location of the <span class="title-ref">ListBox</span> on the screen relative to the top-left corner of the display.

This code in the MouseDown event obtains the indexes of the cell that was double-clicked.

``` xojo
Var row, column As Integer
row = Me.RowFromXY(x, y)
column = Me.ColumnFromXY(x, y)
MessageBox("You double-clicked in cell " + Str(row) + ", " + Str(column))
```

The parameters of RowFRomXY are relative to the top, left corner of the <span class="title-ref">ListBox</span> on a window. If you use the <span class="title-ref">ListBox</span> in a ContainerControl you have to take into account the distance of the container from the window edges.

``` xojo
Var row, column As Integer
row = Me.RowFromXY(System.MouseX - Me.Left - Self.Left - Me.TrueWindow.Left, System.MouseY - Me.Top - Self.Top - Me.TrueWindow.Top)
column = Me.ColumnFromXY(System.MouseX - Me.Left - Me.Parent.Left - Me.TrueWindow.Left, System.MouseY - Me.Top - Me.Parent.Top - Me.TrueWindow.Top)
MessageBox("You double-clicked in cell " + Str(row) + ", " + Str(column))
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Making a cell editable

Use the CellTypeAt or ColumnTypeAt properties to change a cell or column to "inline editable" when you want the user to be able to edit the contents of the <span class="title-ref">ListBox</span>. Then call the EditCellAt method for each cell. This gives the focus to the editable cell and selects the current text of the cell, if any. Typing replaces the cell's contents. When the user presses Tab or Return or clicks in another cell, the cell loses the focus and the contents of the cell are saved.

The following code in the CellClick event makes the cell the user pressed on editable. The parameters row, and column are passed to the function.

``` xojo
Me.CellTypeAt(row, column) = ListBox.CellTypes.TextField
Me.EditCellAt(row, column)
```

When a cell is editable, the ActiveTextControl property is the `TextField</api/deprecated/textfield>` that contains the contents of that cell. You can use this property to set or get the text of the <span class="title-ref">ListBox</span> cell, set the selection, or change other properties of the <span class="title-ref">ListBox</span>'s `TextField</api/deprecated/textfield>`.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Decimal alignment

When you use decimal alignment in a cell or column, you must take into account the fact that the decimal separator is aligned with the right edge of the column or cell. You must pass a negative number to CellAlignmentOffsetAt or ColumnAlignmentOffsetAt to make room for the numbers to the right of the decimal place. The correct value to pass depends on the number of digits to the right of the decimal place in the column or cell.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Resizing columns

There are two "modes" for column resizing. There is no formal mode property. Rather, the "mode" is implicitly set according to whether every column width is specified as an absolute amount. If you specify all columns either in points or as a percentage, you will be using the second mode. If you use an asterisk or leave a column width blank, you will be using the first mode.

- A change to one column width affects the width of another column.

If column i gets bigger, column i+1 gets smaller by the same amount. This mode is great when using a <span class="title-ref">ListBox</span> without a horizontal scrollbar. You turn this mode on when you have at least one column width that is blank, or specified using an asterisk (e.g. "", " ", "*", or "4*").

Note: By design you can't resize the right edge of the last column in this mode. To resize the last column you need to resize the previous column.

- Each column width is independent and can grow or shrink on its own.

You are responsible when the user does this, and you need to provide a horizontal scrollbar so that the user can get to the any headers that have been pushed out of view to the right. You enable this mode by making sure every column width is specified in terms of an absolute pixel width, or a percentage width (e.g. "20", or "35%"). If you use an asterisk or leave a column width blank, you will automatically be using the first mode.

You can switch between mode 1 and 2 at runtime using the same criteria as above.

The `ColumnWidths<listbox.columnwidths>` property is equivalent to the concatenation of all of the ColumnWidthExpressions.

ColumnWidthExpressions are strings and they can represent several different types of column width calculations: absolute points (e.g., "45"), percentages (e.g. "22.3%"), and asterisk widths (or blanks), e.g. " ", "4\*". The value "*" is equivalent to "1*" and can be used to mean "fill the remaining space."

ColumnWidthExpressions retain their type even when a column is resized. This means that if you:

- Resize a window to which a <span class="title-ref">ListBox</span> is locked, it will grow or shrink. The columns grow or shrink as well if their expressions were *-based (unless you use "0*"), or percentage based (0%). If you want them to stay fixed, you need to express the ColumnWidthExpression as an absolute pixel value.
- Resize a column by dragging it internally, it will recompute its percentage or asterisk value. This is so that you can, say, start with a two-column <span class="title-ref">ListBox</span> with no column widths specified (each column will take up half the space). Then drag one column to take up 3/4 of the space, then enlarge the <span class="title-ref">ListBox</span>, and now both column widths will enlarge so that their widths remain in a 3/4 to 1/4 ratio.

Changing the pixel value of a column will not change its fundamental type, but will change the value of that type.

Finally, if you want to create columns that won't get resized, change the UserResizable property for each of the columns in question. If you are using mode 1, you will need to change the UserResizable property for both the column and the one to its left.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Displaying data from a database

A <span class="title-ref">ListBox</span> is often used to display the results of database queries. A <span class="title-ref">ListBox</span> can be populated with the results of a query programmatically. See the example "Database Example" in the Examples folder.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Creating checkbox cells

The CellCheckBoxStateAt method enables you to get or set the value of a tri-state Checkbox cell. Any cell of type `CheckBox<listbox.celltypes>` can store one of three values: Checked, Unchecked, and Indeterminate.

To set up a cell as a Checkbox, use code such as this in the Open event:

``` xojo
Me.CellTypeAt(1, 0) = ListBox.CellTypes.CheckBox
```

To change the state of the cell, use the `VisualStates<checkbox.visualstates>` enumeration of the `CheckBox</api/deprecated/checkbox>` control:

``` xojo
ListBox1.CellCheckBoxStateAt(1, 0) = CheckBox.VisualStates.Indeterminate
```

The Indeterminate state places a minus sign in the checkbox (macOS) or fills in checkbox (Windows and Linux).

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Customized scroll controls

Suppose you want a horizontal scroll bar that leaves room for a pop-up menu. In this example, a `Scrollbar</api/deprecated/scrollbar>` control has been added to the bottom area of the <span class="title-ref">ListBox</span> and a `BevelButton</api/deprecated/bevelbutton>` control has been added to its right. The two controls take up the area that would be used by the built-in horizontal scrollbar.

The `Scrollbar</api/deprecated/scrollbar>` control has the following code in its Open event handler:

``` xojo
Me.Maximum = 50
Me.Minimum = 0
Me.LineStep = 5
```

The values for Maximum and LineStep were chosen to match the total width of the <span class="title-ref">ListBox</span>'s columns. Adjust these values to suit your <span class="title-ref">ListBox</span>. Its ValueChanged event handler has the following line of code:

``` xojo
ListBox1.ScrollPositionX = Me.Value
```

In this way, the user can scroll the <span class="title-ref">ListBox</span> horizontally, bringing all columns into view.

The `BevelButton</api/deprecated/bevelbutton>` enables the user to switch the <span class="title-ref">ListBox</span> between single-line selection and multiple-line selection. The `BevelButton</api/deprecated/bevelbutton>` is set to have a normal menu and its Open event handler populates the menu with two items:

``` xojo
Me.AddRow("Single-line")
Me.AddRow("Multiple-line")
```

The `BevelButton's</api/deprecated/bevelbutton>` Action event sets the value of the <span class="title-ref">ListBox</span>'s SelectionType property:

``` xojo
Select Case Me.MenuValue
Case 0
  Listbox1.RowSelectionType = Listbox.RowSelectionTypes.Single
Case 1
  ListBox1.RowSelectionType = Listbox.RowSelectionTypes.Multiple
End Select
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Adding horizontal and vertical grid lines

You can show horizontal and vertical rules for the entire <span class="title-ref">ListBox</span> using the `GridLinesHorizontalStyle<listbox.gridlineshorizontalstyle>` and `GridLineVerticalStyle<listbox.gridlinesverticalstyle>` properties. You can also display horizontal and verticals rules for specific cells by using the `CellBorderTopAt<listbox.cellbordertopat>`, `CellBorderLeftAt<listbox.cellborderleftat>`, `CellBorderRightAt<listbox.cellborderrightat>`, and `CellBorderBottomAt<listbox.cellborderbottomat>` properties.

The Default value of these properties is equivalent to "None". Other choices are: ThinDotted, ThinSolid, ThickSolid and DoubleThinSolid.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Displaying hierarchical rows

A hierarchical <span class="title-ref">ListBox</span> works like a tree view. Xojo uses the generic terms Expandable Rows to describe this style of <span class="title-ref">ListBox</span>. To allow for expandable rows, set the `AllowExpandableRows<listbox.allowexpandablerows>` property to true then rows can be expanded to display child content (and then collapsed later).

Windows uses plus and minus signs to indicate rows that are parents; macOS and Linux use disclosure triangles.

The following code, which is in the <span class="title-ref">ListBox</span>'s Open event handler, populates a <span class="title-ref">ListBox</span> with expandable rows: The s1 string contains the parent level and sub1 contains the elements that are nested within each of s1's elements. It is a list of comma-delimited lists, with each list delimited by semicolons. The elements of sub1 are initially hidden because they are stored in a hidden column.

``` xojo
Var u As Integer
Var s1, sub1 As String
Me.ColumnWidths = "150,0"
s1 = "Michigan,Ohio,Minnesota"
sub1 = "Grand Blanc,Bad Axe,Flint,Benton Harbor,Detroit;Cleveland,Columbus,Akron,Pleasantville;St. Paul,Frostbite Falls"
u = CountFields(s1, ",")
For i As Integer =1 To u
  If NthField(sub1, ";", i) <> "" Then
    Me.AddExpandableRow("")
    Me.CellValueAt(i - 1, 1) = NthField(sub1, ";", i)
  End If
  Me.CellValueAt(i - 1, 0) = NthField(s1, ",", i)
Next
Me.ColumnCount = 1
```

Note that the AddExpandableRow method, rather than AddRow, is used to add the State names.

The following line of code in the DoubleClick event handler toggles the expanded state of the row that was double-clicked:

``` xojo
Me.RowExpandedAt(Me.SelectedRowIndex) = Not Me.RowExpandedAt(Me.SelectedRowIndex)
```

The following code in the ExpandRow event handler runs when the user double-clicks a collapsed element:

``` xojo
Var s1 As String
Var u As Integer
s1 = Me.CellValueAt(row, 1)
u = CountFields(s1, ",")
For i As Integer = 1 To u
  Me.AddRow("")
  Me.CellValueAt(Me.LastAddedRowIndex, 0) = NthField(s1, ",", i)
Next
```

It creates the sublist rows each time the user double-clicks a collapsed state name.

If the <span class="title-ref">ListBox</span> has the `AllowExpandableRows<listbox.allowexpandablerows>` property selected, then collapsing is handled automatically when the user collapses an item. If `AllowExpandableRows<listbox.allowexpandablerows>` is false, then you need code such as this in the `CollapseRow<listbox.collapserow>` event handler:

``` xojo
Var u, numSubRows As Integer
numSubRows = CountFields(Me.Cell(row, 1), ",")
u = row + 1
For i As Integer = row + numSubRows DownTo u
  Me.RemoveRowAt(i)
Next
```

It removes the rows that were created by the `ExpandRow<listbox.expandrow>` event handler.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Drag and drop

The following example allows the user to drag one row from ListBox1 to ListBox2. ListBox1 has its `AllowRowDragging<listbox.allowrowdragging>` property set to `True</api/language/true>` and its `RowSelectionType<listbox.rowselectiontype>` property set to `Single<listbox.rowselectiontypes>`. Its DragRow event handler is as follows:

``` xojo
Function DragRow (drag As DragItem, row As Integer) As Boolean
  drag.Text = Me.List(row)
  Return True ' allow the drag
End Function
```

ListBox2's Open event handler has the line:

``` xojo
Me.AcceptTextDrop
```

Its DropObject event handler is this:

``` xojo
Sub DropObject(obj As DragItem)
  Me.AddRow(obj.Text) ' adds the dropped text as a new row
End Sub
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Drag and drop multiple rows

The following code allows the user to drag more than one row from ListBox1 to ListBox2. The dragged rows are added to the end of the list.

ListBox1 has its `AllowRowDragging<listbox.allowrowdragging>` property set to `True</api/language/true>`, enabling items in its list to be dragged, and its `RowSelectionType<listbox.rowselectiontype>` property set to `Multiple<listbox.rowselectiontypes>`. Its DragRow event handler is as follows:

``` xojo
Function DragRow (Drag As DragItem, Row As Integer) As Boolean
  Var nRows As Integer
  nRows = Me.ListCount - 1
  For i As Integer = 0 To nRows
    If Me.Selected(i) Then
      Drag.AddItem(0, 0, 20, 4)
      Drag.Text = Me.List(i) ' get text
    End If
  Next
  Return True ' allow the drag
End Function
```

It uses the AddItem method of the `DragItem</api/user_interface/desktop/dragitem>` to add an additional item to the DragItem each selected row. The DropObject event handler then cycles through all items to retrieve all dragged rows.

ListBox2 has the following line of code in its Open event handler. It permits it to receive dragged text.

``` xojo
Me.AcceptTextDrop
```

Its DropObject event handler checks to see if the dragged object is text; if it is, it adds a row to the end of the list and assigns the text property of the dragged object to the new row: It loops through all items in the DragItem until NextItem returns `False</api/language/false>`.

``` xojo
Sub DropObject(obj As DragItem)
  Do
    If obj.TextAvailable Then
      Me.AddRow(obj.Text)
    End If
  Loop Until Not obj.NextItem
End Sub
```

You can also drag from ListBox1 to the desktop to get a text clipping or to another application that supports text drag and drop.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Changing the background color of cells

This code, which is placed in the CellBackgroundPaint event, assigns alternating colors to the rows in a \`ListBox\`:

``` xojo
If row Mod 2 = 0 Then
  g.DrawingColor= &cD2FFF3
Else
  g.DrawingColor= &cD2EDF5
End If
g.FillRectangle(0, 0, g.Width, g.Height)
```

Notes: The CellBackgroundPaint event passes the parameters g (`Graphics</api/graphics/graphics>`), and the row and column numbers (as `Integer</api/data_types/integer>`). You can assign a color to the DrawingColor property by creating it as a constant in the App class or a module and assign the color constant to the DrawingColor property. The following line in the CellTextPaint event draws the text in the preceding example in red:

``` xojo
g.DrawingColor =Color.RGB(255, 0, 0)
```

The CellTextPaint event is passed the coordinates of the suggested starting position to draw text in the parameters x and y. You can use them in a call to the DrawText method to specify the string to draw in a particular cell:

``` xojo
If row = 4 And column = 1 Then
  g.DrawingColor =Color.RGB(255, 0, 0)
  g.DrawText("Payment Overdue!", x, y)
End If
Return True
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Sorting rows

To sort a <span class="title-ref">ListBox</span>, set the column on which the <span class="title-ref">ListBox</span> will be sorted with the `SortingColumn<listbox.sortingcolumn>` property. Specify the sort direction on that column with the `ColumnSortDirectionAt<listbox.columnsortdirectionat>` property, and then do the sort by calling the Sort method.

The following code sorts a <span class="title-ref">ListBox</span> in descending order on the first column.

``` xojo
' first column, descending order
ListBox1.ColumnsortDirectionAt(0) = ListBox.SortDirections.Descending
ListBox1.SortingColumn = 0 ' first column is the sort column
ListBox1.Sort
```

You can also sort a column based on the current value of `ColumnSortDirectionAt<listbox.columnsortdirectionat>` by calling the `PressHeader<listbox.pressheader>` method. This method programmatically clicks the header for the column passed to it.

Note that sorting is based on string comparisons. If you want to sort numbers or CheckBoxes then you have to use a custom sort.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Sorting rows with your own algorithm

Use the `CompareRows<listbox.comparerows>` event handler to perform custom sorting on the displayed data. You will want to use custom sorting to property sort numerical data, which by default sorts as a string. This causes "2" to be greater than "100" because the values are treated as strings. You can also provide a custom sort for CheckBox columns, dates and any other information that you may want to sort differently than how it displays as a string.

The following example uses the `CompareRows<listbox.comparerows>` event to sort columns of numbers numerically:

``` xojo
Function CompareRows(row1 As Integer, row2 As Integer, column As Integer, ByRef result As Integer) As Boolean
  If Val(Me.CellValueAt(row1, column)) > Val(Me.CellValueAt(row2, column)) Then
    result = 1
  Else
    result = -1
  End If

  Return True ' Use the custom sort
End Function
```

With this code in place, the correct (numerical) sorting is done whenever the user clicks the header area. Test to be sure that the custom sort affects only the numerical columns.

To sort dates, store the `SecondsFrom1970<datetime.secondsfrom1970>` (or SQLiteDate) property of the `DateTime</api/data_types/datetime>` in the `CellTagAt<listbox.celltagat>` for the column and use it to sort instead of the displayed value.

## Sample code

Adding a row to ListBox1:

``` xojo
ListBox1.AddRow("October")
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Adding a row at row 1 in ListBox1:

``` xojo
ListBox1.AddRowAt(1, "October")
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Creating a three-column <span class="title-ref">ListBox</span> and adding the headings and the first row of information:

``` xojo
ListBox1.ColumnCount = 3

ListBox1.HasHeader = True
ListBox1.HeaderAt(0) = "Name"
ListBox1.HeaderAt(1) = "Phone"
ListBox1.HeaderAt(2) = "Email"

ListBox1.AddRow("Milton")
ListBox1.CellValueAt(ListBox1.LastAddedRowIndex, 1) = "555-2212"
ListBox1.CellValueAt(ListBox1.LastAddedRowIndex, 2) = "milt@fredonia.com"
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Changing all items in the <span class="title-ref">ListBox</span> to bold, underline:

``` xojo
ListBox1.Bold = True
ListBox1.Underline = True
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Copying the fifth element of ListBox1 to another variable:

``` xojo
Var e As String
e = ListBox1.List(4)
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Adding a column to ListBox1 and setting the widths of the columns to 50 and 65 points, respectively:

``` xojo
ListBox1.ColumnCount = 2
ListBox1.ColumnWidths = "50,65"
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Setting the number of columns of ListBox1 to three and setting the widths of the columns to 60%, 20% and 20% respectively:

``` xojo
ListBox1.ColumnCount = 3
ListBox1.ColumnWidths = "60%,20%,20%"
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

If ListBox1 is 100 points wide and has three columns, the following code will set the columns widths as indicated but the last column will only be 10 points wide instead of 20:

``` xojo
ListBox1.ColumnWidths = "60,30,20"
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

If ListBox1 is 100 points wide and has three columns, the following code will set the columns widths but the last column will not be displayed:

``` xojo
ListBox1.ColumnWidths = "60,40,20"
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Copying the fifth row of the third column of ListBox1 to another variable:

``` xojo
Var e As String
e = ListBox1.CellValueAt(4, 2)
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Assigning a value to the fifth row of the third column of ListBox1:

``` xojo
ListBox1.CellValueAt(4, 2) = "Bill"
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Setting the fifth row of the third column of ListBox1 to bold, italic:

``` xojo
ListBox1.CellBold(4, 2) = True
ListBox1.CellItalic(4, 2) = True
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Adding a row with the text "Users" in the first cell and placing an image of a folder to the left of the text. The picture "usersFolder" has been added to the project.

``` xojo
ListBox1.AddRow("Users")
ListBox1.RowImageAt(0) = UsersFolder
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Setting up the DragRow event handler to allow the user to drag a value from a \`ListBox\`:

``` xojo
Function DragRow(Drag As DragItem, Row As Integer) As Boolean
  Drag.Text = ListBox1.List(Row)
  Return True
End Function
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Summing the numeric values of the selected rows:

``` xojo
Var total As Integer
For i As Integer = 0 To ListBox1.LastRowIndex
  If ListBox1.Selected(i) Then
    total = total + Val(ListBox1.List(i))
  End If
Next
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This code expands the first row of ListBox1 (if it is collapsed) or collapses it (if it was expanded). The row must have been added with the AddFolder method:

``` xojo
ListBox1.ExpandedRowAt(1) = Not ListBox1.ExpandedRowAt(1)
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This code populates a three-column <span class="title-ref">ListBox</span> with headings:

``` xojo
ListBox1.HasHeader = True
ListBox1.HeaderAt(0) = "ID"
ListBox1.HeaderAt(1) = "JobTitle"
ListBox1.HeaderAt(2) = "Name"
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This code sets up a <span class="title-ref">ListBox</span> with four visible columns plus one hidden column. Column zero is hidden:

``` xojo
Me.ColumnCount = 5
Me.ColumnWidths = "0,25%,25%,25%,25%"
Me.HasHeader = True
Me.HeaderAt(0) = "ID"
Me.HeaderAt(1) = "FirstName"
Me.HeaderAt(2) = "LastName"
Me.HeaderAt(3) = "Phone"
Me.HeaderAt(4) = "Zip"
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The following line of code displays the value of the hidden column in the selected row:

``` xojo
MessageBox(ListBox1.CellValueAt(ListBox1.SelectedRowIndex, 0))
```

## Compatibility

All project types on all supported operating systems.

## See also

`RectControl</api/deprecated/rectcontrol>` parent class; `TextField</api/deprecated/textfield>` controls; `DatabaseColumn</api/databases/databasecolumn>`, `ListColumn</api/deprecated/listcolumn>`, `RowSet</api/databases/rowset>` classes
