A listbox is used to select one or more of a list of strings. The
strings are displayed in a scrolling box, with the selected string(s)
marked in reverse video. A listbox can be single selection (if an item
is selected, the previous selection is removed) or multiple selection
(clicking an item toggles the item on or off independently of other
selections). This is controlled by changing the style passed to the
constructor.
List box elements are numbered from zero. Their number is limited in
some platforms – for example, around 2000 on GTK.
A listbox callback gets an event EVT_COMMAND_LISTBOX_SELECT for single
clicks, and EVT_COMMAND_LISTBOX_DOUBLE_CLICKED for double clicks.
LB_SINGLE |
Single-selection list. |
LB_MULTIPLE |
Multiple-selection list: the user can toggle multipleitems on and off. |
LB_EXTENDED |
Extended-selection list: the user canselect multiple items using the SHIFT key and the mouse or special key combinations. |
LB_HSCROLL |
Create horizontal scrollbar if contents are too wide (Windows only). |
LB_ALWAYS_SB |
Always show a vertical scrollbar. |
LB_NEEDED_SB |
Only create a vertical scrollbar if needed. |
LB_SORT |
The listbox contents are sorted in alphabetical order. |
Note that LB_SINGLE
, LB_MULTIPLE
and LB_EXTENDED
styles are mutually exclusive and you can specify at most one of them (single
selection is the default).
See also window styles overview.
evt_listbox(id) { | event | … } | Process a EVT_COMMAND_LISTBOX_SELECTED event,when an item on the list is selected. |
evt_listbox_dclick(id) { | event | … } | Process a EVT_COMMAND_LISTBOX_DOUBLECLICKED event,when the listbox is double-clicked. |
Choice, ComboBox, ListCtrl,
CommandEvent
Integer style = 0,
Validator validator = DEFAULT_VALIDATOR,
String name = “listBox”)
Constructor, creating and showing a list box.
Integer style = 0,
Validator validator = DEFAULT_VALIDATOR,
String name = “listBox”)
Creates the listbox for two-step construction. See ListBox.new for further details.
Deselects an item in the list box.
This applies to multiple selection listboxes only.
Returns an array of integers corresponding to the selected items in the
listbox. Use this with a multiple selection listbox.
ControlWithItems#get_selection, ControlWithItems#get_string_selection, ControlWithItems#set_selection
Insert a number of strings before the specified position.
Determines whether an item is selected.
true if the given item is selected, false otherwise.
nil
)
Clears the list box and adds the given strings to it.
Set the specified item to be the first visible item. Windows only.
[This page automatically generated from the Textile source at 2023-06-09 00:45:35 +0000]