wxComboBox

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.

Derived from

wxControlWithItems
wxControl
wxWindow
wxEvtHandler
wxObject

Include files

<wx/combobox.h>

Window styles

wxCB_SIMPLE Creates a combobox with a permanently displayed list. Windows only.
wxCB_DROPDOWN Creates a combobox with a drop-down list.
wxCB_READONLY Same as wxCB_DROPDOWN but only the strings specified as the combobox choices can be selected, it is impossible to select (even from a program) a string which is not in the choices list.
wxCB_SORT Sorts the entries in the list alphabetically.

See also window styles overview.

Event handling

EVT_COMBOBOX(id, func) Process a wxEVT_COMMAND_COMBOBOX_SELECTED event, when an item on the list is selected. Note that calling GetValue returns the new value of selection.
EVT_TEXT(id, func) Process a wxEVT_COMMAND_TEXT_UPDATED event, when the combobox text changes.
EVT_TEXT_ENTER(id, func) Process a wxEVT_COMMAND_TEXT_ENTER event, when <RETURN> is pressed in the combobox.

See also

wxListBox, wxTextCtrl, wxChoice, wxCommandEvent



wxComboBox::wxComboBox



wxComboBox(void)

Default constructor.



wxComboBox(wxWindow* parent, wxWindowID id, const wxString& value = ``", const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, int n, const wxString choices[], long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = ``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 = ``comboBox")

Constructor, creating and showing a combobox.

Parameters

parent
Parent window. Must not be NULL.

id
Window identifier. A value of -1 indicates a default value.

value
Initial selection string. An empty string indicates no selection.

pos
Window position.

size
Window size. If the default size (-1, -1) 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.

See also

wxComboBox::Create, wxValidator

wxPython での注意点: The wxComboBox 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.



wxComboBox::~wxComboBox



~wxComboBox(void)

Destructor, destroying the combobox.



wxComboBox::Create



bool Create(wxWindow* parent, wxWindowID id, const wxString& value = ``", const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, int n, const wxString choices[], long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = ``comboBox")



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 = ``comboBox")

Creates the combobox for two-step construction. Derived classes should call or replace this function. See wxComboBox::wxComboBox for further details.



wxComboBox::CanCopy

bool CanCopy(void) const

Returns true if the combobox is editable and there is a text selection to copy to the clipboard. Only available on Windows.



wxComboBox::CanCut

bool CanCut(void) const

Returns true if the combobox is editable and there is a text selection to copy to the clipboard. Only available on Windows.



wxComboBox::CanPaste

bool CanPaste(void) const

Returns true if the combobox is editable and there is text on the clipboard that can be pasted into the text field. Only available on Windows.



wxComboBox::CanRedo

bool CanRedo(void) const

Returns true if the combobox is editable and the last undo can be redone. Only available on Windows.



wxComboBox::CanUndo

bool CanUndo(void) const

Returns true if the combobox is editable and the last edit can be undone. Only available on Windows.



wxComboBox::Copy



void Copy(void)

Copies the selected text to the clipboard.



wxComboBox::Cut



void Cut(void)

Copies the selected text to the clipboard and removes the selection.



wxComboBox::GetInsertionPoint

long GetInsertionPoint(void) const

Returns the insertion point for the combobox's text field.



wxComboBox::GetLastPosition

virtual wxTextPos GetLastPosition(void) const

Returns the last position in the combobox text field.



wxComboBox::GetValue

wxString GetValue(void) const

Returns the current value in the combobox text field.



wxComboBox::Paste



void Paste(void)

Pastes text from the clipboard to the text field.



wxComboBox::Redo



void Redo(void)

Redoes the last undo in the text field. Windows only.



wxComboBox::Replace



void Replace(long from, long to, const wxString& text)

Replaces the text between two positions with the given text, in the combobox text field.

Parameters

from
The first position.

to
The second position.

text
The text to insert.



wxComboBox::Remove



void Remove(long from, long to)

Removes the text between the two positions in the combobox text field.

Parameters

from
The first position.

to
The last position.



wxComboBox::SetInsertionPoint



void SetInsertionPoint(long pos)

Sets the insertion point in the combobox text field.

Parameters

pos
The new insertion point.



wxComboBox::SetInsertionPointEnd



void SetInsertionPointEnd(void)

Sets the insertion point at the end of the combobox text field.



wxComboBox::SetSelection



void SetSelection(long from, long to)

Selects the text between the two positions, in the combobox text field.

Parameters

from
The first position.

to
The second position.

wxPython での注意点: This method is called SetMark in wxPython, SetSelection name is kept for wxControlWithItems::SetSelection.



wxComboBox::SetValue



void SetValue(const wxString& text)

Sets the text for the combobox text field.

NB: For a combobox with wxCB_READONLY style the string must be in the combobox choices list, otherwise the call to SetValue() is ignored.

Parameters

text
The text to set.



wxComboBox::Undo



void Undo(void)

Undoes the last edit in the text field. Windows only.

ymasuda 平成17年11月19日