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.
}
32 See also
\helpref{window styles overview
}{windowstyles
}.
34 \wxheading{Event handling
}
37 \begin{twocollist
}\itemsep=
0pt
38 \twocolitem{{\bf EVT
\_COMBOBOX(id, func)
}}{Process a wxEVT
\_COMMAND\_COMBOBOX\_SELECTED event,
39 when an item on the list is selected. Note that calling
40 \helpref{GetValue
}{wxcomboboxgetvalue
} returns the new value of selection.
}
41 \twocolitem{{\bf EVT
\_TEXT(id, func)
}}{Process a wxEVT
\_COMMAND\_TEXT\_UPDATED event,
42 when the combobox text changes.
}
43 \twocolitem{{\bf EVT
\_TEXT\_ENTER(id, func)
}}{Process a wxEVT
\_COMMAND\_TEXT\_ENTER event,
44 when <RETURN> is pressed in the combobox.
}
49 \helpref{wxListBox
}{wxlistbox
},
\helpref{wxTextCtrl
}{wxtextctrl
},
\helpref{wxChoice
}{wxchoice
},
50 \rtfsp\helpref{wxCommandEvent
}{wxcommandevent
}
52 \latexignore{\rtfignore{\wxheading{Members
}}}
54 \membersection{wxComboBox::wxComboBox
}\label{wxcomboboxctor
}
56 \func{}{wxComboBox
}{\void}
60 \func{}{wxComboBox
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
61 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
62 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
63 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
65 \func{}{wxComboBox
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
66 \param{const wxString\&
}{value
},
\param{const wxPoint\&
}{ pos
},
\param{const wxSize\&
}{ size
},
\rtfsp
67 \param{const wxArrayString\&
}{choices
},
\rtfsp
68 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
70 Constructor, creating and showing a combobox.
72 \wxheading{Parameters
}
74 \docparam{parent
}{Parent window. Must not be NULL.
}
76 \docparam{id
}{Window identifier. A value of -
1 indicates a default value.
}
78 \docparam{value
}{Initial selection string. An empty string indicates no selection.
}
80 \docparam{pos
}{Window position.
}
82 \docparam{size
}{Window size. If the default size (-
1, -
1) is specified then the window is sized
85 \docparam{n
}{Number of strings with which to initialise the control.
}
87 \docparam{choices
}{An array of strings with which to initialise the control.
}
89 \docparam{style
}{Window style. See
\helpref{wxComboBox
}{wxcombobox
}.
}
91 \docparam{validator
}{Window validator.
}
93 \docparam{name
}{Window name.
}
97 \helpref{wxComboBox::Create
}{wxcomboboxcreate
},
\helpref{wxValidator
}{wxvalidator
}
99 \pythonnote{The wxComboBox constructor in wxPython reduces the
{\tt n
}
100 and
{\tt choices
} arguments are to a single argument, which is
103 \perlnote{In wxPerl there is just an array reference in place of
{\tt n
}
106 \membersection{wxComboBox::
\destruct{wxComboBox
}}\label{wxcomboboxdtor
}
108 \func{}{\destruct{wxComboBox
}}{\void}
110 Destructor, destroying the combobox.
112 \membersection{wxComboBox::Create
}\label{wxcomboboxcreate
}
114 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
115 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
116 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
117 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
119 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
120 \param{const wxString\&
}{value
},
\param{const wxPoint\&
}{ pos
},
\param{const wxSize\&
}{ size
},
\rtfsp
121 \param{const wxArrayString\&
}{choices
},
\rtfsp
122 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
124 Creates the combobox for two-step construction. Derived classes
125 should call or replace this function. See
\helpref{wxComboBox::wxComboBox
}{wxcomboboxctor
}\rtfsp
128 \membersection{wxComboBox::CanCopy
}\label{wxcomboboxcancopy
}
130 \constfunc{bool
}{CanCopy
}{\void}
132 Returns true if the combobox is editable and there is a text selection to copy to the clipboard.
133 Only available on Windows.
135 \membersection{wxComboBox::CanCut
}\label{wxcomboboxcancut
}
137 \constfunc{bool
}{CanCut
}{\void}
139 Returns true if the combobox is editable and there is a text selection to copy to the clipboard.
140 Only available on Windows.
142 \membersection{wxComboBox::CanPaste
}\label{wxcomboboxcanpaste
}
144 \constfunc{bool
}{CanPaste
}{\void}
146 Returns true if the combobox is editable and there is text on the clipboard that can be pasted into the
147 text field. Only available on Windows.
149 \membersection{wxComboBox::CanRedo
}\label{wxcomboboxcanredo
}
151 \constfunc{bool
}{CanRedo
}{\void}
153 Returns true if the combobox is editable and the last undo can be redone.
154 Only available on Windows.
156 \membersection{wxComboBox::CanUndo
}\label{wxcomboboxcanundo
}
158 \constfunc{bool
}{CanUndo
}{\void}
160 Returns true if the combobox is editable and the last edit can be undone.
161 Only available on Windows.
163 \membersection{wxComboBox::Copy
}\label{wxcomboboxcopy
}
165 \func{void
}{Copy
}{\void}
167 Copies the selected text to the clipboard.
169 \membersection{wxComboBox::Cut
}\label{wxcomboboxcut
}
171 \func{void
}{Cut
}{\void}
173 Copies the selected text to the clipboard and removes the selection.
175 \membersection{wxComboBox::GetInsertionPoint
}\label{wxcomboboxgetinsertionpoint
}
177 \constfunc{long
}{GetInsertionPoint
}{\void}
179 Returns the insertion point for the combobox's text field.
181 \membersection{wxComboBox::GetLastPosition
}\label{wxcomboboxgetlastposition
}
183 \constfunc{virtual wxTextPos
}{GetLastPosition
}{\void}
185 Returns the last position in the combobox text field.
187 \membersection{wxComboBox::GetValue
}\label{wxcomboboxgetvalue
}
189 \constfunc{wxString
}{GetValue
}{\void}
191 Returns the current value in the combobox text field.
193 \membersection{wxComboBox::Paste
}\label{wxcomboboxpaste
}
195 \func{void
}{Paste
}{\void}
197 Pastes text from the clipboard to the text field.
199 \membersection{wxComboBox::Redo
}\label{wxcomboboxredo
}
201 \func{void
}{Redo
}{\void}
203 Redoes the last undo in the text field. Windows only.
205 \membersection{wxComboBox::Replace
}\label{wxcomboboxreplace
}
207 \func{void
}{Replace
}{\param{long
}{ from
},
\param{long
}{ to
},
\param{const wxString\&
}{text
}}
209 Replaces the text between two positions with the given text, in the combobox text field.
211 \wxheading{Parameters
}
213 \docparam{from
}{The first position.
}
215 \docparam{to
}{The second position.
}
217 \docparam{text
}{The text to insert.
}
219 \membersection{wxComboBox::Remove
}\label{wxcomboboxremove
}
221 \func{void
}{Remove
}{\param{long
}{ from
},
\param{long
}{ to
}}
223 Removes the text between the two positions in the combobox text field.
225 \wxheading{Parameters
}
227 \docparam{from
}{The first position.
}
229 \docparam{to
}{The last position.
}
231 \membersection{wxComboBox::SetInsertionPoint
}\label{wxcomboboxsetinsertionpoint
}
233 \func{void
}{SetInsertionPoint
}{\param{long
}{ pos
}}
235 Sets the insertion point in the combobox text field.
237 \wxheading{Parameters
}
239 \docparam{pos
}{The new insertion point.
}
241 \membersection{wxComboBox::SetInsertionPointEnd
}\label{wxcomboboxsetinsertionpointend
}
243 \func{void
}{SetInsertionPointEnd
}{\void}
245 Sets the insertion point at the end of the combobox text field.
247 \membersection{wxComboBox::SetSelection
}\label{wxcomboboxsetselection
}
249 \func{void
}{SetSelection
}{\param{long
}{ from
},
\param{long
}{ to
}}
251 Selects the text between the two positions, in the combobox text field.
253 \wxheading{Parameters
}
255 \docparam{from
}{The first position.
}
257 \docparam{to
}{The second position.
}
259 \pythonnote{This method is called
{\tt SetMark
} in wxPython,
{\tt SetSelection
}
261 \helpref{wxControlWithItems::SetSelection
}{wxcontrolwithitemssetselection
}.
}
263 \membersection{wxComboBox::SetValue
}\label{wxcomboboxsetvalue
}
265 \func{void
}{SetValue
}{\param{const wxString\&
}{text
}}
267 Sets the text for the combobox text field.
269 {\bf NB:
} For a combobox with
{\tt wxCB
\_READONLY} style the string must be in
270 the combobox choices list, otherwise the call to SetValue() is ignored.
272 \wxheading{Parameters
}
274 \docparam{text
}{The text to set.
}
276 \membersection{wxComboBox::Undo
}\label{wxcomboboxundo
}
278 \func{void
}{Undo
}{\void}
280 Undoes the last edit in the text field. Windows only.