#include <wx/combobox.h>
A combobox is like a combination of an edit control and a listbox.
It can be displayed as static list with editable or read-only text field; or a drop-down list with text field; or a drop-down list without a text field.
A combobox permits a single selection only. Combobox items are numbered from zero.
If you need a customized combobox, have a look at wxComboCtrl, wxOwnerDrawnComboBox, wxComboPopup and the ready-to-use wxBitmapComboBox.
Please refer to wxTextEntry documentation for the description of methods operating with the text entry part of the combobox.
This class supports the following styles:
The following event handler macros redirect the events to member function handlers 'func' with prototypes like:
Event macros for events emitted by this class:
![]() | ![]() | ![]() |
wxMSW appearance | wxGTK appearance | wxMac appearance |
Public Member Functions | |
wxComboBox () | |
Default constructor. | |
wxComboBox (wxWindow *parent, wxWindowID id, const wxString &value=wxEmptyString, 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=wxComboBoxNameStr) | |
Constructor, creating and showing a combobox. | |
wxComboBox (wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxComboBoxNameStr) | |
Constructor, creating and showing a combobox. | |
virtual | ~wxComboBox () |
Destructor, destroying the combobox. | |
virtual int | GetCurrentSelection () const |
Returns the item being selected right now. | |
virtual long | GetInsertionPoint () const |
Same as wxTextEntry::GetInsertionPoint(). | |
virtual void | SetSelection (long from, long to) |
Same as wxTextEntry::SetSelection(). | |
virtual void | SetValue (const wxString &text) |
Sets the text for the combobox text field. | |
bool | Create (wxWindow *parent, wxWindowID id, const wxString &value=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n=0, const wxString choices[]=(const wxString *) NULL, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxComboBoxNameStr) |
Creates the combobox for two-step construction. | |
bool | Create (wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxComboBoxNameStr) |
Creates the combobox for two-step construction. |
wxComboBox::wxComboBox | ( | ) |
Default constructor.
wxComboBox::wxComboBox | ( | wxWindow * | parent, | |
wxWindowID | id, | |||
const wxString & | value = wxEmptyString , |
|||
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 = wxComboBoxNameStr | |||
) |
Constructor, creating and showing a combobox.
parent | Parent window. Must not be NULL. | |
id | Window identifier. The value wxID_ANY indicates a default value. | |
value | Initial selection string. An empty string indicates no selection. Notice that for the controls with wxCB_READONLY style this string must be one of the valid choices if it is not empty. | |
pos | Window position. If wxDefaultPosition is specified then a default position is chosen. | |
size | Window size. If wxDefaultSize is specified then the window is sized appropriately. | |
n | Number of strings with which to initialise the control. | |
choices | An array of strings with which to initialise the control. | |
style | Window style. See wxComboBox. | |
validator | Window validator. | |
name | Window name. |
wxPython Note: The wxComboBox constructor in wxPython reduces the n and choices arguments are to a single argument, which is a list of strings.
wxPerl Note: Not supported by wxPerl.
wxComboBox::wxComboBox | ( | wxWindow * | parent, | |
wxWindowID | id, | |||
const wxString & | value, | |||
const wxPoint & | pos, | |||
const wxSize & | size, | |||
const wxArrayString & | choices, | |||
long | style = 0 , |
|||
const wxValidator & | validator = wxDefaultValidator , |
|||
const wxString & | name = wxComboBoxNameStr | |||
) |
Constructor, creating and showing a combobox.
parent | Parent window. Must not be NULL. | |
id | Window identifier. The value wxID_ANY indicates a default value. | |
value | Initial selection string. An empty string indicates no selection. | |
pos | Window position. | |
size | Window size. If wxDefaultSize is specified then the window is sized appropriately. | |
choices | An array of strings with which to initialise the control. | |
style | Window style. See wxComboBox. | |
validator | Window validator. | |
name | Window name. |
wxPython Note: The wxComboBox constructor in wxPython reduces the n and choices arguments are to a single argument, which is a list of strings.
wxPerl Note: Use an array reference for the choices parameter.
virtual wxComboBox::~wxComboBox | ( | ) | [virtual] |
Destructor, destroying the combobox.
bool wxComboBox::Create | ( | wxWindow * | parent, | |
wxWindowID | id, | |||
const wxString & | value, | |||
const wxPoint & | pos, | |||
const wxSize & | size, | |||
const wxArrayString & | choices, | |||
long | style = 0 , |
|||
const wxValidator & | validator = wxDefaultValidator , |
|||
const wxString & | name = wxComboBoxNameStr | |||
) |
Creates the combobox for two-step construction.
Derived classes should call or replace this function. See wxComboBox() for further details.
Reimplemented in wxBitmapComboBox.
bool wxComboBox::Create | ( | wxWindow * | parent, | |
wxWindowID | id, | |||
const wxString & | value = wxEmptyString , |
|||
const wxPoint & | pos = wxDefaultPosition , |
|||
const wxSize & | size = wxDefaultSize , |
|||
int | n = 0 , |
|||
const wxString | choices[] = (const wxString *) NULL , |
|||
long | style = 0 , |
|||
const wxValidator & | validator = wxDefaultValidator , |
|||
const wxString & | name = wxComboBoxNameStr | |||
) |
Creates the combobox for two-step construction.
Derived classes should call or replace this function. See wxComboBox() for further details.
Reimplemented in wxBitmapComboBox.
virtual int wxComboBox::GetCurrentSelection | ( | ) | const [virtual] |
Returns the item being selected right now.
This function does the same things as wxChoice::GetCurrentSelection() and returns the item currently selected in the dropdown list if it's open or the same thing as wxControlWithItems::GetSelection() otherwise.
virtual long wxComboBox::GetInsertionPoint | ( | ) | const [virtual] |
Same as wxTextEntry::GetInsertionPoint().
Reimplemented from wxTextEntry.
virtual void wxComboBox::SetSelection | ( | long | from, | |
long | to | |||
) | [virtual] |
Same as wxTextEntry::SetSelection().
wxPython Note: This method is called SetMark() in wxPython, "SetSelection" is kept for wxControlWithItems::SetSelection().
Reimplemented from wxTextEntry.
virtual void wxComboBox::SetValue | ( | const wxString & | text | ) | [virtual] |
Sets the text for the combobox text field.
Notice that this method will generate a wxEVT_COMMAND_TEXT_UPDATED event, use wxTextEntry::ChangeValue() if this is undesirable.
wxCB_READONLY
style the string must be in the combobox choices list, otherwise the call to SetValue() is ignored.text | The text to set. |
Reimplemented from wxTextEntry.
![]() |
[ top ] |