1 \section{\class{wxComboBox
}}\label{wxcombobox
}
3 A combobox is like a combination of an edit control and a listbox. It can be
4 displayed as static list with editable or read-only text field; or a drop-down list with
5 text field; or a drop-down list without a text field.
7 A combobox permits a single selection only. Combobox items are numbered from zero.
9 \wxheading{Derived from
}
11 \helpref{wxControlWithItems
}{wxcontrolwithitems
}\\
12 \helpref{wxControl
}{wxcontrol
}\\
13 \helpref{wxWindow
}{wxwindow
}\\
14 \helpref{wxEvtHandler
}{wxevthandler
}\\
15 \helpref{wxObject
}{wxobject
}
17 \wxheading{Include files
}
21 \wxheading{Window styles
}
23 \begin{twocollist
}\itemsep=
0pt
24 \twocolitem{\windowstyle{wxCB
\_SIMPLE}}{Creates a combobox with a permanently displayed list. Windows only.
}
25 \twocolitem{\windowstyle{wxCB
\_DROPDOWN}}{Creates a combobox with a drop-down list.
}
26 \twocolitem{\windowstyle{wxCB
\_READONLY}}{Same as wxCB
\_DROPDOWN but only the
27 strings specified as the combobox choices can be selected, it is impossible to
28 select (even from a program) a string which is not in the choices list.
}
29 \twocolitem{\windowstyle{wxCB
\_SORT}}{Sorts the entries in the list alphabetically.
}
30 \twocolitem{\windowstyle{wxPROCESS
\_ENTER}}{The control will generate
31 the event wxEVT
\_COMMAND\_TEXT\_ENTER (otherwise pressing Enter key
32 is either processed internally by the control or used for navigation between
33 dialog controls). Windows only.
}
36 See also
\helpref{window styles overview
}{windowstyles
}.
38 \wxheading{Event handling
}
41 \begin{twocollist
}\itemsep=
0pt
42 \twocolitem{{\bf EVT
\_COMBOBOX(id, func)
}}{Process a wxEVT
\_COMMAND\_COMBOBOX\_SELECTED event,
43 when an item on the list is selected. Note that calling
44 \helpref{GetValue
}{wxcomboboxgetvalue
} returns the new value of selection.
}
45 \twocolitem{{\bf EVT
\_TEXT(id, func)
}}{Process a wxEVT
\_COMMAND\_TEXT\_UPDATED event,
46 when the combobox text changes.
}
47 \twocolitem{{\bf EVT
\_TEXT\_ENTER(id, func)
}}{Process a wxEVT
\_COMMAND\_TEXT\_ENTER event,
48 when <RETURN> is pressed in the combobox.
}
53 \helpref{wxListBox
}{wxlistbox
},
\helpref{wxTextCtrl
}{wxtextctrl
},
\helpref{wxChoice
}{wxchoice
},
54 \rtfsp\helpref{wxCommandEvent
}{wxcommandevent
}
56 \latexignore{\rtfignore{\wxheading{Members
}}}
59 \membersection{wxComboBox::wxComboBox
}\label{wxcomboboxctor
}
61 \func{}{wxComboBox
}{\void}
65 \func{}{wxComboBox
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
66 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
67 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
68 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
70 \func{}{wxComboBox
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
71 \param{const wxString\&
}{value
},
\param{const wxPoint\&
}{ pos
},
\param{const wxSize\&
}{ size
},
\rtfsp
72 \param{const wxArrayString\&
}{choices
},
\rtfsp
73 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
75 Constructor, creating and showing a combobox.
77 \wxheading{Parameters
}
79 \docparam{parent
}{Parent window. Must not be NULL.
}
81 \docparam{id
}{Window identifier. A value of -
1 indicates a default value.
}
83 \docparam{value
}{Initial selection string. An empty string indicates no selection.
}
85 \docparam{pos
}{Window position.
}
87 \docparam{size
}{Window size. If the default size (-
1, -
1) is specified then the window is sized
90 \docparam{n
}{Number of strings with which to initialise the control.
}
92 \docparam{choices
}{An array of strings with which to initialise the control.
}
94 \docparam{style
}{Window style. See
\helpref{wxComboBox
}{wxcombobox
}.
}
96 \docparam{validator
}{Window validator.
}
98 \docparam{name
}{Window name.
}
102 \helpref{wxComboBox::Create
}{wxcomboboxcreate
},
\helpref{wxValidator
}{wxvalidator
}
104 \pythonnote{The wxComboBox constructor in wxPython reduces the
{\tt n
}
105 and
{\tt choices
} arguments are to a single argument, which is
108 \perlnote{In wxPerl there is just an array reference in place of
{\tt n
}
112 \membersection{wxComboBox::
\destruct{wxComboBox
}}\label{wxcomboboxdtor
}
114 \func{}{\destruct{wxComboBox
}}{\void}
116 Destructor, destroying the combobox.
119 \membersection{wxComboBox::Create
}\label{wxcomboboxcreate
}
121 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
122 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
123 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
124 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
126 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
127 \param{const wxString\&
}{value
},
\param{const wxPoint\&
}{ pos
},
\param{const wxSize\&
}{ size
},
\rtfsp
128 \param{const wxArrayString\&
}{choices
},
\rtfsp
129 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
131 Creates the combobox for two-step construction. Derived classes
132 should call or replace this function. See
\helpref{wxComboBox::wxComboBox
}{wxcomboboxctor
}\rtfsp
136 \membersection{wxComboBox::CanCopy
}\label{wxcomboboxcancopy
}
138 \constfunc{bool
}{CanCopy
}{\void}
140 Returns true if the combobox is editable and there is a text selection to copy to the clipboard.
141 Only available on Windows.
144 \membersection{wxComboBox::CanCut
}\label{wxcomboboxcancut
}
146 \constfunc{bool
}{CanCut
}{\void}
148 Returns true if the combobox is editable and there is a text selection to copy to the clipboard.
149 Only available on Windows.
152 \membersection{wxComboBox::CanPaste
}\label{wxcomboboxcanpaste
}
154 \constfunc{bool
}{CanPaste
}{\void}
156 Returns true if the combobox is editable and there is text on the clipboard that can be pasted into the
157 text field. Only available on Windows.
160 \membersection{wxComboBox::CanRedo
}\label{wxcomboboxcanredo
}
162 \constfunc{bool
}{CanRedo
}{\void}
164 Returns true if the combobox is editable and the last undo can be redone.
165 Only available on Windows.
168 \membersection{wxComboBox::CanUndo
}\label{wxcomboboxcanundo
}
170 \constfunc{bool
}{CanUndo
}{\void}
172 Returns true if the combobox is editable and the last edit can be undone.
173 Only available on Windows.
176 \membersection{wxComboBox::Copy
}\label{wxcomboboxcopy
}
178 \func{void
}{Copy
}{\void}
180 Copies the selected text to the clipboard.
183 \membersection{wxComboBox::Cut
}\label{wxcomboboxcut
}
185 \func{void
}{Cut
}{\void}
187 Copies the selected text to the clipboard and removes the selection.
190 \membersection{wxComboBox::GetInsertionPoint
}\label{wxcomboboxgetinsertionpoint
}
192 \constfunc{long
}{GetInsertionPoint
}{\void}
194 Returns the insertion point for the combobox's text field.
196 \textbf{Note:
} Under wxMSW, this function always returns $
0$ if the combobox
197 doesn't have the focus.
200 \membersection{wxComboBox::GetLastPosition
}\label{wxcomboboxgetlastposition
}
202 \constfunc{virtual wxTextPos
}{GetLastPosition
}{\void}
204 Returns the last position in the combobox text field.
207 \membersection{wxComboBox::GetValue
}\label{wxcomboboxgetvalue
}
209 \constfunc{wxString
}{GetValue
}{\void}
211 Returns the current value in the combobox text field.
214 \membersection{wxComboBox::Paste
}\label{wxcomboboxpaste
}
216 \func{void
}{Paste
}{\void}
218 Pastes text from the clipboard to the text field.
221 \membersection{wxComboBox::Redo
}\label{wxcomboboxredo
}
223 \func{void
}{Redo
}{\void}
225 Redoes the last undo in the text field. Windows only.
228 \membersection{wxComboBox::Replace
}\label{wxcomboboxreplace
}
230 \func{void
}{Replace
}{\param{long
}{ from
},
\param{long
}{ to
},
\param{const wxString\&
}{text
}}
232 Replaces the text between two positions with the given text, in the combobox text field.
234 \wxheading{Parameters
}
236 \docparam{from
}{The first position.
}
238 \docparam{to
}{The second position.
}
240 \docparam{text
}{The text to insert.
}
243 \membersection{wxComboBox::Remove
}\label{wxcomboboxremove
}
245 \func{void
}{Remove
}{\param{long
}{ from
},
\param{long
}{ to
}}
247 Removes the text between the two positions in the combobox text field.
249 \wxheading{Parameters
}
251 \docparam{from
}{The first position.
}
253 \docparam{to
}{The last position.
}
256 \membersection{wxComboBox::SetInsertionPoint
}\label{wxcomboboxsetinsertionpoint
}
258 \func{void
}{SetInsertionPoint
}{\param{long
}{ pos
}}
260 Sets the insertion point in the combobox text field.
262 \wxheading{Parameters
}
264 \docparam{pos
}{The new insertion point.
}
267 \membersection{wxComboBox::SetInsertionPointEnd
}\label{wxcomboboxsetinsertionpointend
}
269 \func{void
}{SetInsertionPointEnd
}{\void}
271 Sets the insertion point at the end of the combobox text field.
274 \membersection{wxComboBox::SetSelection
}\label{wxcomboboxsetselection
}
276 \func{void
}{SetSelection
}{\param{long
}{ from
},
\param{long
}{ to
}}
278 Selects the text between the two positions, in the combobox text field.
280 \wxheading{Parameters
}
282 \docparam{from
}{The first position.
}
284 \docparam{to
}{The second position.
}
286 \pythonnote{This method is called
{\tt SetMark
} in wxPython,
{\tt SetSelection
}
288 \helpref{wxControlWithItems::SetSelection
}{wxcontrolwithitemssetselection
}.
}
291 \membersection{wxComboBox::SetValue
}\label{wxcomboboxsetvalue
}
293 \func{void
}{SetValue
}{\param{const wxString\&
}{text
}}
295 Sets the text for the combobox text field.
297 {\bf NB:
} For a combobox with
{\tt wxCB
\_READONLY} style the string must be in
298 the combobox choices list, otherwise the call to SetValue() is ignored.
300 \wxheading{Parameters
}
302 \docparam{text
}{The text to set.
}
305 \membersection{wxComboBox::Undo
}\label{wxcomboboxundo
}
307 \func{void
}{Undo
}{\void}
309 Undoes the last edit in the text field. Windows only.