]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/combobox.tex
fix for wxExecute(subprocess which produces a lot of output) bug
[wxWidgets.git] / docs / latex / wx / combobox.tex
CommitLineData
a660d684
KB
1\section{\class{wxComboBox}}\label{wxcombobox}
2
3A combobox is like a combination of an edit control and a listbox. It can be
4displayed as static list with editable or read-only text field; or a drop-down list with
5text field; or a drop-down list without a text field.
6
7A combobox permits a single selection only. Combobox items are numbered from zero.
8
9\wxheading{Derived from}
10
11\helpref{wxChoice}{wxchoice}\\
12\helpref{wxControl}{wxcontrol}\\
13\helpref{wxWindow}{wxwindow}\\
14\helpref{wxEvtHandler}{wxevthandler}\\
15\helpref{wxObject}{wxobject}
16
954b8ae6
JS
17\wxheading{Include files}
18
f6bcfd97 19<wx/combobox.h>
954b8ae6 20
a660d684
KB
21\wxheading{Window styles}
22
23\begin{twocollist}\itemsep=0pt
9c884972 24\twocolitem{\windowstyle{wxCB\_SIMPLE}}{Creates a combobox with a permanently displayed list. Windows only. }
a660d684 25\twocolitem{\windowstyle{wxCB\_DROPDOWN}}{Creates a combobox with a drop-down list.}
3ca6a5f0
BP
26\twocolitem{\windowstyle{wxCB\_READONLY}}{Same as wxCB\_DROPDOWN but only the
27strings specified as the combobox choices can be selected, it is impossible to
28select (even from a program) a string which is not in the choices list.}
a660d684
KB
29\twocolitem{\windowstyle{wxCB\_SORT}}{Sorts the entries in the list alphabetically.}
30\end{twocollist}
31
32See also \helpref{window styles overview}{windowstyles}.
33
5de76427
JS
34\wxheading{Event handling}
35
36\twocolwidtha{7cm}
37\begin{twocollist}\itemsep=0pt
38\twocolitem{{\bf EVT\_COMBOBOX(id, func)}}{Process a wxEVT\_COMMAND\_COMBOBOX\_SELECTED event,
39when an item on the list is selected.}
40\twocolitem{{\bf EVT\_TEXT(id, func)}}{Process a wxEVT\_COMMAND\_TEXT\_UPDATED event,
41when the combobox text changes.}
42\end{twocollist}
43
a660d684
KB
44\wxheading{See also}
45
5de76427
JS
46\helpref{wxListBox}{wxlistbox}, \helpref{wxTextCtrl}{wxtextctrl}, \helpref{wxChoice}{wxchoice},
47\rtfsp\helpref{wxCommandEvent}{wxcommandevent}
a660d684
KB
48
49\latexignore{\rtfignore{\wxheading{Members}}}
50
51\membersection{wxComboBox::wxComboBox}\label{wxcomboboxconstr}
52
53\func{}{wxComboBox}{\void}
54
55Default constructor.
56
eaaa6a06 57\func{}{wxComboBox}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
a660d684 58\param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
eaaa6a06
JS
59\param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
60\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
a660d684
KB
61
62Constructor, creating and showing a combobox.
63
64\wxheading{Parameters}
65
66\docparam{parent}{Parent window. Must not be NULL.}
67
68\docparam{id}{Window identifier. A value of -1 indicates a default value.}
69
70\docparam{pos}{Window position.}
71
72\docparam{size}{Window size. If the default size (-1, -1) is specified then the window is sized
73appropriately.}
74
75\docparam{n}{Number of strings with which to initialise the control.}
76
77\docparam{choices}{An array of strings with which to initialise the control.}
78
79\docparam{style}{Window style. See \helpref{wxComboBox}{wxcombobox}.}
80
81\docparam{validator}{Window validator.}
82
83\docparam{name}{Window name.}
84
85\wxheading{See also}
86
87\helpref{wxComboBox::Create}{wxcomboboxcreate}, \helpref{wxValidator}{wxvalidator}
88
c9110876
VS
89\pythonnote{The wxComboBox constructor in wxPython reduces the {\tt n}
90and {\tt choices} arguments are to a single argument, which is
06d20283
RD
91a list of strings.}
92
5873607e
VZ
93\perlnote{In wxPerl there is just an array reference in place of {\tt n}
94and {\tt choices}.}
06d20283 95
a660d684
KB
96\membersection{wxComboBox::\destruct{wxComboBox}}
97
98\func{}{\destruct{wxComboBox}}{\void}
99
100Destructor, destroying the combobox.
101
102\membersection{wxComboBox::Append}\label{wxcomboboxappend}
103
104\func{void}{Append}{\param{const wxString\& }{item}}
105
106Adds the item to the end of the combobox.
107
9c884972 108\func{void}{Append}{\param{const wxString\& }{ item}, \param{void* }{clientData}}
a660d684
KB
109
110Adds the item to the end of the combobox, associating the given data
111with the item.
112
113\wxheading{Parameters}
114
115\docparam{item}{The string to add.}
116
117\docparam{clientData}{Client data to associate with the item.}
118
119\membersection{wxComboBox::Clear}\label{wxcomboboxclear}
120
121\func{void}{Clear}{\void}
122
123Clears all strings from the combobox.
124
125\membersection{wxComboBox::Create}\label{wxcomboboxcreate}
126
eaaa6a06 127\func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
a660d684 128\param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
eaaa6a06
JS
129\param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
130\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
a660d684
KB
131
132Creates the combobox for two-step construction. Derived classes
133should call or replace this function. See \helpref{wxComboBox::wxComboBox}{wxcomboboxconstr}\rtfsp
134for further details.
135
136\membersection{wxComboBox::Copy}\label{wxcomboboxcopy}
137
138\func{void}{Copy}{\void}
139
140Copies the selected text to the clipboard.
141
142\membersection{wxComboBox::Cut}\label{wxcomboboxcut}
143
144\func{void}{Cut}{\void}
145
146Copies the selected text to the clipboard and removes the selection.
147
148\membersection{wxComboBox::Delete}\label{wxcomboboxdelete}
149
eaaa6a06 150\func{void}{Delete}{\param{int}{ n}}
a660d684
KB
151
152Deletes an item from the combobox.
153
154\wxheading{Parameters}
155
156\docparam{n}{The item to delete, starting from zero.}
157
a660d684
KB
158\membersection{wxComboBox::FindString}\label{wxcomboboxfindstring}
159
160\func{int}{FindString}{\param{const wxString\& }{string}}
161
162Finds a choice matching the given string.
163
164\wxheading{Parameters}
165
166\docparam{string}{The item to find.}
167
168\wxheading{Return value}
169
170The position if found, or -1 if not found.
171
172\membersection{wxComboBox::GetClientData}\label{wxcomboboxgetclientdata}
173
9c884972 174\constfunc{void*}{GetClientData}{\param{int}{ n}}
a660d684
KB
175
176Returns a pointer to the client data associated with the given item (if any).
177
178\wxheading{Parameters}
179
180\docparam{n}{An item, starting from zero.}
181
182\wxheading{Return value}
183
184A pointer to the client data, or NULL if the item was not found.
185
186\membersection{wxComboBox::GetInsertionPoint}\label{wxcomboboxgetinsertionpoint}
187
188\constfunc{long}{GetInsertionPoint}{\void}
189
190Returns the insertion point for the combobox's text field.
191
192\membersection{wxComboBox::GetLastPosition}\label{wxcomboboxgetlastposition}
193
194\constfunc{long}{GetLastPosition}{\void}
195
196Returns the last position in the combobox text field.
197
198\membersection{wxComboBox::GetSelection}\label{wxcomboboxgetselection}
199
200\constfunc{int}{GetSelection}{\void}
201
202Gets the position of the selected string, or -1 if there is no selection.
203
204\membersection{wxComboBox::GetString}\label{wxcomboboxgetstring}
205
206\constfunc{wxString}{GetString}{\param{int}{ n}}
207
208Returns the string at position {\it n}.
209
210\wxheading{Parameters}
211
212\docparam{n}{The item position, starting from zero.}
213
214\wxheading{Return value}
215
216The string if the item is found, otherwise the empty string.
217
218\membersection{wxComboBox::GetStringSelection}\label{wxcomboboxgetstringselection}
219
220\constfunc{wxString}{GetStringSelection}{\void}
221
222Gets the selected string.
223
224\membersection{wxComboBox::GetValue}\label{wxcomboboxgetvalue}
225
226\constfunc{wxString}{GetValue}{\void}
227
228Returns the current value in the combobox text field.
229
230\membersection{wxComboBox::Number}\label{wxcomboboxnumber}
231
232\constfunc{int}{Number}{\void}
233
234Returns the number of items in the combobox list.
5b6aa0ff 235%TODO: make this GetNumber or GetCount?
a660d684
KB
236
237\membersection{wxComboBox::Paste}\label{wxcomboboxpaste}
238
239\func{void}{Paste}{\void}
240
241Pastes text from the clipboard to the text field.
242
243\membersection{wxComboBox::Replace}\label{wxcomboboxreplace}
244
eaaa6a06 245\func{void}{Replace}{\param{long}{ from}, \param{long}{ to}, \param{const wxString\& }{text}}
a660d684
KB
246
247Replaces the text between two positions with the given text, in the combobox text field.
248
249\wxheading{Parameters}
250
251\docparam{from}{The first position.}
252
253\docparam{to}{The second position.}
254
255\docparam{text}{The text to insert.}
256
257\membersection{wxComboBox::Remove}\label{wxcomboboxremove}
258
eaaa6a06 259\func{void}{Remove}{\param{long}{ from}, \param{long}{ to}}
a660d684
KB
260
261Removes the text between the two positions in the combobox text field.
262
263\wxheading{Parameters}
264
265\docparam{from}{The first position.}
266
267\docparam{to}{The last position.}
268
269\membersection{wxComboBox::SetClientData}\label{wxcomboboxsetclientdata}
270
9c884972 271\func{void}{SetClientData}{\param{int}{ n}, \param{void* }{data}}
a660d684
KB
272
273Associates the given client data pointer with the given item.
274
275\wxheading{Parameters}
276
277\docparam{n}{The zero-based item.}
278
279\docparam{data}{The client data.}
280
281\membersection{wxComboBox::SetInsertionPoint}\label{wxcomboboxsetinsertionpoint}
282
eaaa6a06 283\func{void}{SetInsertionPoint}{\param{long}{ pos}}
a660d684
KB
284
285Sets the insertion point in the combobox text field.
286
287\wxheading{Parameters}
288
289\docparam{pos}{The new insertion point.}
290
291\membersection{wxComboBox::SetInsertionPointEnd}\label{wxcomboboxsetinsertionpointend}
292
293\func{void}{SetInsertionPointEnd}{\void}
294
295Sets the insertion point at the end of the combobox text field.
296
297\membersection{wxComboBox::SetSelection}\label{wxcomboboxsetselection}
298
eaaa6a06 299\func{void}{SetSelection}{\param{int}{ n}}
a660d684 300
953704c1
RR
301Selects the given item in the combobox list. This does not cause a
302wxEVT\_COMMAND\_COMBOBOX\_SELECTED event to get emitted.
a660d684 303
eaaa6a06 304\func{void}{SetSelection}{\param{long}{ from}, \param{long}{ to}}
a660d684
KB
305
306Selects the text between the two positions, in the combobox text field.
307
308\wxheading{Parameters}
309
310\docparam{n}{The zero-based item to select.}
311
312\docparam{from}{The first position.}
313
314\docparam{to}{The second position.}
315
c9110876 316\pythonnote{The second form of this method is called {\tt SetMark} in
a2c75a02
RD
317wxPython.}
318
a660d684
KB
319\membersection{wxComboBox::SetValue}\label{wxcomboboxsetvalue}
320
321\func{void}{SetValue}{\param{const wxString\& }{text}}
322
323Sets the text for the combobox text field.
324
3ca6a5f0
BP
325{\bf NB:} For a combobox with {\tt wxCB\_READONLY} style the string must be in
326the combobox choices list, otherwise the call to SetValue() is ignored.
327
a660d684
KB
328\wxheading{Parameters}
329
330\docparam{text}{The text to set.}
331
332