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).
List box elements are numbered from zero. Their number is limited in some platforms (e.g. ca. 2000 on GTK).
A listbox callback gets an event wxEVT_COMMAND_LISTBOX_SELECT for single clicks, and wxEVT_COMMAND_LISTBOX_DOUBLE_CLICKED for double clicks.
Derived from
wxControlWithItems
wxControl
wxWindow
wxEvtHandler
wxObject
Include files
<wx/listbox.h>
Window styles
Note that wxLB_SINGLE, wxLB_MULTIPLE and wxLB_EXTENDED styles are mutually exclusive and you can specify at most one of them (single selection is the default).
See also window styles overview.
Event handling
EVT_LISTBOX(id, func) | Process a wxEVT_COMMAND_LISTBOX_SELECTED event, when an item on the list is selected. |
---|---|
EVT_LISTBOX_DCLICK(id, func) | Process a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event, when the listbox is double-clicked. |
See also
wxChoice, wxComboBox, wxListCtrl, wxCommandEvent
Default constructor.
Constructor, creating and showing a list box.
Parameters
See also
wxListBox::Create, wxValidator
wxPython での注意点: The wxListBox constructor in wxPython reduces the n and choices arguments are to a single argument, which is a list of strings.
wxPerl での注意点: In wxPerl there is just an array reference in place of n and choices.
Destructor, destroying the list box.
Creates the listbox for two-step construction. See wxListBox::wxListBox for further details.
Deselects an item in the list box.
Parameters
Remarks
This applies to multiple selection listboxes only.
int GetSelections(wxArrayInt& selections) const
Fill an array of ints with the positions of the currently selected items.
Parameters
Return value
The number of selections.
Remarks
Use this with a multiple selection listbox.
See also
wxControlWithItems::GetSelection, wxControlWithItems::GetStringSelection, wxControlWithItems::SetSelection
wxPython での注意点: The wxPython version of this method takes no parameters and returns a tuple of the selected items.
wxPerl での注意点: In wxPerl this method takes no parameters and return the selected items as a list.
Insert the given number of strings before the specified position.
Parameters
wxPython での注意点: The first two parameters are collapsed into a single parameter for wxPython, which is a list of strings.
wxPerl での注意点: In wxPerl there is just an array reference in place of nItems and items.
Determines whether an item is selected.
Parameters
Return value
true if the given item is selected, false otherwise.
Clears the list box and adds the given strings to it.
Parameters
Remarks
You may free the array from the calling program after this function has been called.
Set the specified item to be the first visible item. Windows only.
Parameters