contents up previous next

wxchoice

a choice item is used to select one of a list of strings. unlike a listbox, only the selection is visible until the user pulls down the menu of choices.

derived from

wxcontrolwithitems
wxcontrol
wxwindow
wxevthandler
wxobject

include files

<wx/choice.h>

window styles

there are no special styles for wxchoice.

see also window styles overview.

event handling

evt_choice(id, func) process a wxevt_command_choice_selected event, when an item on the list is selected.

see also

wxlistbox, wxcombobox, wxcommandevent

members

wxchoice::wxchoice
wxchoice::~wxchoice
wxchoice::create
wxchoice::getcolumns
wxchoice::getcurrentselection
wxchoice::setcolumns


wxchoice::wxchoice

wxchoice()

default constructor.

wxchoice(wxwindow *parent, wxwindowid id, const wxpoint& pos, const wxsize& size, int n, const wxstring choices[], long style = 0, const wxvalidator& validator = wxdefaultvalidator, const wxstring& name = "choice")

wxchoice(wxwindow *parent, wxwindowid id, const wxpoint& pos, const wxsize& size, const wxarraystring& choices, long style = 0, const wxvalidator& validator = wxdefaultvalidator, const wxstring& name = "choice")

constructor, creating and showing a choice.

parameters

parent

id

pos

size

n

choices

style

validator

name

see also

wxchoice::create, wxvalidator

wxpython note: the wxchoice 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.


wxchoice::~wxchoice

~wxchoice()

destructor, destroying the choice item.


wxchoice::create

bool create(wxwindow *parent, wxwindowid id, const wxpoint& pos, const wxsize& size, int n, const wxstring choices[], long style = 0, const wxvalidator& validator = wxdefaultvalidator, const wxstring& name = "choice")

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 = "choice")

creates the choice for two-step construction. see wxchoice::wxchoice.


wxchoice::getcolumns

int getcolumns() const

gets the number of columns in this choice item.

remarks

this is implemented for motif only and always returns 1 for the other platforms.


wxchoice::getcurrentselection

int getcurrentselection() const

unlike getselection which only returns the accepted selection value, i.e. the selection in the control once the user closes the dropdown list, this function returns the current selection. that is, while the dropdown list is shown, it returns the currently selected item in it. when it is not shown, its result is the same as for the other function.

this function is new since wxwidgets version 2.6.2 (before this version getselection itself behaved like this).


wxchoice::setcolumns

void setcolumns(int n = 1)

sets the number of columns in this choice item.

parameters

n

remarks

this is implemented for motif only and doesn't do anything under other platforms.