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
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::Append
wxChoice::Clear
wxChoice::Create
wxChoice::Delete
wxChoice::FindString
wxChoice::GetColumns
wxChoice::GetClientData
wxChoice::GetCount
wxChoice::GetSelection
wxChoice::GetString
wxChoice::GetStringSelection
wxChoice::Number
wxChoice::SetClientData
wxChoice::SetColumns
wxChoice::SetSelection
wxChoice::SetString
wxChoice::SetStringSelection
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")
Constructor, creating and showing a choice.
Parameters
parent
id
pos
size
n
choices
style
validator
name
See also
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()
Destructor, destroying the choice item.
void Append(const wxString& item)
Adds the item to the end of the choice control.
void Append(const wxString& item, void* clientData)
Adds the item to the end of the combobox, associating the given data with the item.
Parameters
item
clientData
void Clear()
Clears the strings from the choice item.
bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style = 0, const wxString& name = "choice")
Creates the choice for two-step construction. See wxChoice::wxChoice.
void Delete(int n)
Deletes the item with the given index from the control.
Parameters
n
int FindString(const wxString& string) const
Finds a choice matching the given string.
Parameters
string
Return value
Returns the position if found, or -1 if not found.
int GetColumns() const
Gets the number of columns in this choice item.
Remarks
This is implemented for Motif only.
void* GetClientData(int n) const
Returns a pointer to the client data associated with the given item (if any).
Parameters
n
Return value
A pointer to the client data, or NULL if the item was not found.
int GetCount() const
Returns the number of items in the choice.
int GetSelection() const
Gets the id (position) of the selected string, or -1 if there is no selection.
wxString GetString(int n) const
Returns the string at the given position.
Parameters
n
Return value
The string at the given position, or the empty string if n is invalid.
wxString GetStringSelection() const
Gets the selected string, or the empty string if no string is selected.
int Number() const
Obsolescence note: This method is obsolete and was replaced with GetCount, please use the new method in the new code. This method is only available if wxWindows was compiled with WXWIN_COMPATIBILITY_2_2 defined and will disappear completely in future versions.
Returns the number of strings in the choice control.
void SetClientData(int n, void* data)
Associates the given client data pointer with the given item.
Parameters
n
data
void SetColumns(int n = 1)
Sets the number of columns in this choice item.
Parameters
n
Remarks
This is implemented for Motif only.
void SetSelection(int n)
Sets the choice by passing the desired string position. This does not cause a wxEVT_COMMAND_CHOICE_SELECTED event to get emitted.
Parameters
n
See also
void SetString(int n, const wxString& text)
Replaces the specified string in the control with another one.
Parameters
n
text
NB: This method is currently not implemented in wxGTK.
void SetStringSelection(const wxString& string)
Sets the choice by passing the desired string. This does not cause a wxEVT_COMMAND_CHOICE_SELECTED event to get emitted.
Parameters
string
See also