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{wxChoice
}{wxchoice
}\\
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.
}
40 \twocolitem{{\bf EVT
\_TEXT(id, func)
}}{Process a wxEVT
\_COMMAND\_TEXT\_UPDATED event,
41 when the combobox text changes.
}
46 \helpref{wxListBox
}{wxlistbox
},
\helpref{wxTextCtrl
}{wxtextctrl
},
\helpref{wxChoice
}{wxchoice
},
47 \rtfsp\helpref{wxCommandEvent
}{wxcommandevent
}
49 \latexignore{\rtfignore{\wxheading{Members
}}}
51 \membersection{wxComboBox::wxComboBox
}\label{wxcomboboxconstr
}
53 \func{}{wxComboBox
}{\void}
57 \func{}{wxComboBox
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
58 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
59 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
60 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
62 Constructor, creating and showing a combobox.
64 \wxheading{Parameters
}
66 \docparam{parent
}{Parent window. Must not be NULL.
}
68 \docparam{id
}{Window identifier. A value of -
1 indicates a default value.
}
70 \docparam{pos
}{Window position.
}
72 \docparam{size
}{Window size. If the default size (-
1, -
1) is specified then the window is sized
75 \docparam{n
}{Number of strings with which to initialise the control.
}
77 \docparam{choices
}{An array of strings with which to initialise the control.
}
79 \docparam{style
}{Window style. See
\helpref{wxComboBox
}{wxcombobox
}.
}
81 \docparam{validator
}{Window validator.
}
83 \docparam{name
}{Window name.
}
87 \helpref{wxComboBox::Create
}{wxcomboboxcreate
},
\helpref{wxValidator
}{wxvalidator
}
89 \pythonnote{The wxComboBox constructor in wxPython reduces the
{\tt n
}
90 and
{\tt choices
} arguments are to a single argument, which is
93 \perlnote{In wxPerl there is just an array reference in place of
{\tt n
}
96 \membersection{wxComboBox::
\destruct{wxComboBox
}}
98 \func{}{\destruct{wxComboBox
}}{\void}
100 Destructor, destroying the combobox.
102 \membersection{wxComboBox::Append
}\label{wxcomboboxappend
}
104 \func{void
}{Append
}{\param{const wxString\&
}{item
}}
106 Adds the item to the end of the combobox.
108 \func{void
}{Append
}{\param{const wxString\&
}{ item
},
\param{void*
}{clientData
}}
110 Adds the item to the end of the combobox, associating the given data
113 \wxheading{Parameters
}
115 \docparam{item
}{The string to add.
}
117 \docparam{clientData
}{Client data to associate with the item.
}
119 \membersection{wxComboBox::Clear
}\label{wxcomboboxclear
}
121 \func{void
}{Clear
}{\void}
123 Clears all strings from the combobox.
125 \membersection{wxComboBox::Create
}\label{wxcomboboxcreate
}
127 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
128 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
129 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
130 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
132 Creates the combobox for two-step construction. Derived classes
133 should call or replace this function. See
\helpref{wxComboBox::wxComboBox
}{wxcomboboxconstr
}\rtfsp
136 \membersection{wxComboBox::Copy
}\label{wxcomboboxcopy
}
138 \func{void
}{Copy
}{\void}
140 Copies the selected text to the clipboard.
142 \membersection{wxComboBox::Cut
}\label{wxcomboboxcut
}
144 \func{void
}{Cut
}{\void}
146 Copies the selected text to the clipboard and removes the selection.
148 \membersection{wxComboBox::Delete
}\label{wxcomboboxdelete
}
150 \func{void
}{Delete
}{\param{int
}{ n
}}
152 Deletes an item from the combobox.
154 \wxheading{Parameters
}
156 \docparam{n
}{The item to delete, starting from zero.
}
158 \membersection{wxComboBox::FindString
}\label{wxcomboboxfindstring
}
160 \func{int
}{FindString
}{\param{const wxString\&
}{string
}}
162 Finds a choice matching the given string.
164 \wxheading{Parameters
}
166 \docparam{string
}{The item to find.
}
168 \wxheading{Return value
}
170 The position if found, or -
1 if not found.
172 \membersection{wxComboBox::GetClientData
}\label{wxcomboboxgetclientdata
}
174 \constfunc{void*
}{GetClientData
}{\param{int
}{ n
}}
176 Returns a pointer to the client data associated with the given item (if any).
178 \wxheading{Parameters
}
180 \docparam{n
}{An item, starting from zero.
}
182 \wxheading{Return value
}
184 A pointer to the client data, or NULL if the item was not found.
186 \membersection{wxComboBox::GetInsertionPoint
}\label{wxcomboboxgetinsertionpoint
}
188 \constfunc{long
}{GetInsertionPoint
}{\void}
190 Returns the insertion point for the combobox's text field.
192 \membersection{wxComboBox::GetLastPosition
}\label{wxcomboboxgetlastposition
}
194 \constfunc{long
}{GetLastPosition
}{\void}
196 Returns the last position in the combobox text field.
198 \membersection{wxComboBox::GetSelection
}\label{wxcomboboxgetselection
}
200 \constfunc{int
}{GetSelection
}{\void}
202 Gets the position of the selected string, or -
1 if there is no selection.
204 \membersection{wxComboBox::GetString
}\label{wxcomboboxgetstring
}
206 \constfunc{wxString
}{GetString
}{\param{int
}{ n
}}
208 Returns the string at position
{\it n
}.
210 \wxheading{Parameters
}
212 \docparam{n
}{The item position, starting from zero.
}
214 \wxheading{Return value
}
216 The string if the item is found, otherwise the empty string.
218 \membersection{wxComboBox::GetStringSelection
}\label{wxcomboboxgetstringselection
}
220 \constfunc{wxString
}{GetStringSelection
}{\void}
222 Gets the selected string.
224 \membersection{wxComboBox::GetValue
}\label{wxcomboboxgetvalue
}
226 \constfunc{wxString
}{GetValue
}{\void}
228 Returns the current value in the combobox text field.
230 \membersection{wxComboBox::Number
}\label{wxcomboboxnumber
}
232 \constfunc{int
}{Number
}{\void}
234 Returns the number of items in the combobox list.
235 %TODO: make this GetNumber or GetCount?
237 \membersection{wxComboBox::Paste
}\label{wxcomboboxpaste
}
239 \func{void
}{Paste
}{\void}
241 Pastes text from the clipboard to the text field.
243 \membersection{wxComboBox::Replace
}\label{wxcomboboxreplace
}
245 \func{void
}{Replace
}{\param{long
}{ from
},
\param{long
}{ to
},
\param{const wxString\&
}{text
}}
247 Replaces the text between two positions with the given text, in the combobox text field.
249 \wxheading{Parameters
}
251 \docparam{from
}{The first position.
}
253 \docparam{to
}{The second position.
}
255 \docparam{text
}{The text to insert.
}
257 \membersection{wxComboBox::Remove
}\label{wxcomboboxremove
}
259 \func{void
}{Remove
}{\param{long
}{ from
},
\param{long
}{ to
}}
261 Removes the text between the two positions in the combobox text field.
263 \wxheading{Parameters
}
265 \docparam{from
}{The first position.
}
267 \docparam{to
}{The last position.
}
269 \membersection{wxComboBox::SetClientData
}\label{wxcomboboxsetclientdata
}
271 \func{void
}{SetClientData
}{\param{int
}{ n
},
\param{void*
}{data
}}
273 Associates the given client data pointer with the given item.
275 \wxheading{Parameters
}
277 \docparam{n
}{The zero-based item.
}
279 \docparam{data
}{The client data.
}
281 \membersection{wxComboBox::SetInsertionPoint
}\label{wxcomboboxsetinsertionpoint
}
283 \func{void
}{SetInsertionPoint
}{\param{long
}{ pos
}}
285 Sets the insertion point in the combobox text field.
287 \wxheading{Parameters
}
289 \docparam{pos
}{The new insertion point.
}
291 \membersection{wxComboBox::SetInsertionPointEnd
}\label{wxcomboboxsetinsertionpointend
}
293 \func{void
}{SetInsertionPointEnd
}{\void}
295 Sets the insertion point at the end of the combobox text field.
297 \membersection{wxComboBox::SetSelection
}\label{wxcomboboxsetselection
}
299 \func{void
}{SetSelection
}{\param{int
}{ n
}}
301 Selects the given item in the combobox list. This does not cause a
302 wxEVT
\_COMMAND\_COMBOBOX\_SELECTED event to get emitted.
304 \func{void
}{SetSelection
}{\param{long
}{ from
},
\param{long
}{ to
}}
306 Selects the text between the two positions, in the combobox text field.
308 \wxheading{Parameters
}
310 \docparam{n
}{The zero-based item to select.
}
312 \docparam{from
}{The first position.
}
314 \docparam{to
}{The second position.
}
316 \pythonnote{The second form of this method is called
{\tt SetMark
} in
319 \membersection{wxComboBox::SetValue
}\label{wxcomboboxsetvalue
}
321 \func{void
}{SetValue
}{\param{const wxString\&
}{text
}}
323 Sets the text for the combobox text field.
325 {\bf NB:
} For a combobox with
{\tt wxCB
\_READONLY} style the string must be in
326 the combobox choices list, otherwise the call to SetValue() is ignored.
328 \wxheading{Parameters
}
330 \docparam{text
}{The text to set.
}