wxlistboxa 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 may be limited under some platforms. a listbox callback gets an event wxevt_command_listbox_selected for single clicks, and wxevt_command_listbox_double_clicked for double clicks. derived from
wxcontrolwithitems 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
see also wxchoice, wxcombobox, wxlistctrl, wxcommandevent members
wxlistbox::wxlistbox
wxlistbox::wxlistboxwxlistbox() default constructor. wxlistbox(wxwindow* parent, wxwindowid id, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, int n = 0, const wxstring choices[] = null, long style = 0, const wxvalidator& validator = wxdefaultvalidator, const wxstring& name = "listbox") wxlistbox(wxwindow* parent, wxwindowid id, const wxpoint& pos, const wxsize& size, const wxarraystring& choices, long style = 0, const wxvalidator& validator = wxdefaultvalidator, const wxstring& name = "listbox") constructor, creating and showing a list box. parameters parent
id
pos
size
n
choices
style
validator
name
see also wxlistbox::create, wxvalidator wxpython note: the wxlistbox constructor in wxpython reduces the n and choices arguments are to a single argument, which is a list of strings. wxperl note: in wxperl there is just an array reference in place of n and choices.
wxlistbox::~wxlistboxvoid ~wxlistbox() destructor, destroying the list box.
wxlistbox::createbool create(wxwindow* parent, wxwindowid id, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, int n, const wxstring choices[] = null, long style = 0, const wxvalidator& validator = wxdefaultvalidator, const wxstring& name = "listbox") bool create(wxwindow* parent, wxwindowid id, const wxpoint& pos, const wxsize& size, const wxarraystring& choices, long style = 0, const wxvalidator& validator = wxdefaultvalidator, const wxstring& name = "listbox") creates the listbox for two-step construction. see wxlistbox::wxlistbox for further details.
wxlistbox::deselectvoid deselect(int n) deselects an item in the list box. parameters n
remarks this applies to multiple selection listboxes only.
wxlistbox::getselectionsint getselections(wxarrayint& selections) const fill an array of ints with the positions of the currently selected items. parameters selections
return value the number of selections. remarks use this with a multiple selection listbox. see also wxcontrolwithitems::getselection, wxcontrolwithitems::getstringselection, wxcontrolwithitems::setselection wxpython note: the wxpython version of this method takes no parameters and returns a tuple of the selected items. wxperl note: in wxperl this method takes no parameters and return the selected items as a list.
wxlistbox::insertitemsvoid insertitems(int nitems, const wxstring *items, unsigned int pos) void insertitems(const wxarraystring& nitems, unsigned int pos) insert the given number of strings before the specified position. parameters nitems
items
pos
wxpython note: the first two parameters are collapsed into a single parameter for wxpython, which is a list of strings. wxperl note: in wxperl there is just an array reference in place of nitems and items.
wxlistbox::hittestint hittest(const wxpoint point) const returns the item located at point, or wxnot_found if there is no item located at point. this function is new since wxwidgets version 2.7.0. it is currently implemented for wxmsw, wxmac and wxgtk2 ports. parameters point
return value item located at point, or wxnot_found if unimplemented or the item does not exist.
wxlistbox::isselectedbool isselected(int n) const determines whether an item is selected. parameters n
return value true if the given item is selected, false otherwise.
wxlistbox::setvoid set(int n, const wxstring* choices, void **clientdata = null) void set(const wxarraystring& choices, void **clientdata = null) clears the list box and adds the given strings to it. parameters n
choices
clientdata
remarks you may free the array from the calling program after this function has been called.
wxlistbox::setfirstitemvoid setfirstitem(int n) void setfirstitem(const wxstring& string) set the specified item to be the first visible item. parameters n
string
|