]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/combobox.tex
add @DATE@, @TIME@ and @TITLE@ macros to HTML printing (extended/modified patch 1528679)
[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
bed5584e 11\helpref{wxControlWithItems}{wxcontrolwithitems}\\
a660d684
KB
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 29\twocolitem{\windowstyle{wxCB\_SORT}}{Sorts the entries in the list alphabetically.}
591087ed 30\twocolitem{\windowstyle{wxTE\_PROCESS\_ENTER}}{The control will generate
5090e3ad
JS
31the event wxEVT\_COMMAND\_TEXT\_ENTER (otherwise pressing Enter key
32is either processed internally by the control or used for navigation between
33dialog controls). Windows only.}
5f6475c1
VZ
34\twocolitem{\windowstyle{wxTE\_FILENAME}}{Should be used for the controls
35containing file names. This currently just enables file names auto-completion
36(and only under Windows for now) but can have other effects in the future.}
a660d684
KB
37\end{twocollist}
38
39See also \helpref{window styles overview}{windowstyles}.
40
5de76427
JS
41\wxheading{Event handling}
42
43\twocolwidtha{7cm}
44\begin{twocollist}\itemsep=0pt
45\twocolitem{{\bf EVT\_COMBOBOX(id, func)}}{Process a wxEVT\_COMMAND\_COMBOBOX\_SELECTED event,
7d8268a1 46when an item on the list is selected. Note that calling
13bcc348 47\helpref{GetValue}{wxcomboboxgetvalue} returns the new value of selection.}
5de76427
JS
48\twocolitem{{\bf EVT\_TEXT(id, func)}}{Process a wxEVT\_COMMAND\_TEXT\_UPDATED event,
49when the combobox text changes.}
3980000c
RR
50\twocolitem{{\bf EVT\_TEXT\_ENTER(id, func)}}{Process a wxEVT\_COMMAND\_TEXT\_ENTER event,
51when <RETURN> is pressed in the combobox.}
5de76427
JS
52\end{twocollist}
53
a660d684
KB
54\wxheading{See also}
55
5de76427
JS
56\helpref{wxListBox}{wxlistbox}, \helpref{wxTextCtrl}{wxtextctrl}, \helpref{wxChoice}{wxchoice},
57\rtfsp\helpref{wxCommandEvent}{wxcommandevent}
a660d684
KB
58
59\latexignore{\rtfignore{\wxheading{Members}}}
60
3782aa47 61
f510b7b2 62\membersection{wxComboBox::wxComboBox}\label{wxcomboboxctor}
a660d684
KB
63
64\func{}{wxComboBox}{\void}
65
66Default constructor.
67
eaaa6a06 68\func{}{wxComboBox}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
a660d684 69\param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
89971c77 70\param{int}{ n = 0}, \param{const wxString }{choices[] = NULL},\rtfsp
eaaa6a06 71\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
a660d684 72
56b88f12
MB
73\func{}{wxComboBox}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
74\param{const wxString\& }{value}, \param{const wxPoint\&}{ pos}, \param{const wxSize\&}{ size},\rtfsp
75\param{const wxArrayString\& }{choices},\rtfsp
76\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
77
a660d684
KB
78Constructor, creating and showing a combobox.
79
80\wxheading{Parameters}
81
82\docparam{parent}{Parent window. Must not be NULL.}
83
84\docparam{id}{Window identifier. A value of -1 indicates a default value.}
85
2b5f62a0
VZ
86\docparam{value}{Initial selection string. An empty string indicates no selection.}
87
a660d684
KB
88\docparam{pos}{Window position.}
89
90\docparam{size}{Window size. If the default size (-1, -1) is specified then the window is sized
91appropriately.}
92
93\docparam{n}{Number of strings with which to initialise the control.}
94
95\docparam{choices}{An array of strings with which to initialise the control.}
96
97\docparam{style}{Window style. See \helpref{wxComboBox}{wxcombobox}.}
98
99\docparam{validator}{Window validator.}
100
101\docparam{name}{Window name.}
102
103\wxheading{See also}
104
105\helpref{wxComboBox::Create}{wxcomboboxcreate}, \helpref{wxValidator}{wxvalidator}
106
c9110876
VS
107\pythonnote{The wxComboBox constructor in wxPython reduces the {\tt n}
108and {\tt choices} arguments are to a single argument, which is
06d20283
RD
109a list of strings.}
110
5873607e
VZ
111\perlnote{In wxPerl there is just an array reference in place of {\tt n}
112and {\tt choices}.}
06d20283 113
3782aa47 114
f510b7b2 115\membersection{wxComboBox::\destruct{wxComboBox}}\label{wxcomboboxdtor}
a660d684
KB
116
117\func{}{\destruct{wxComboBox}}{\void}
118
119Destructor, destroying the combobox.
120
3782aa47 121
a660d684
KB
122\membersection{wxComboBox::Create}\label{wxcomboboxcreate}
123
eaaa6a06 124\func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
a660d684 125\param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
eaaa6a06
JS
126\param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
127\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
a660d684 128
56b88f12
MB
129\func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
130\param{const wxString\& }{value}, \param{const wxPoint\&}{ pos}, \param{const wxSize\&}{ size},\rtfsp
131\param{const wxArrayString\& }{choices},\rtfsp
132\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
133
a660d684 134Creates the combobox for two-step construction. Derived classes
f510b7b2 135should call or replace this function. See \helpref{wxComboBox::wxComboBox}{wxcomboboxctor}\rtfsp
a660d684
KB
136for further details.
137
3782aa47 138
150e31d2
JS
139\membersection{wxComboBox::CanCopy}\label{wxcomboboxcancopy}
140
141\constfunc{bool}{CanCopy}{\void}
142
143Returns true if the combobox is editable and there is a text selection to copy to the clipboard.
144Only available on Windows.
145
3782aa47 146
150e31d2
JS
147\membersection{wxComboBox::CanCut}\label{wxcomboboxcancut}
148
149\constfunc{bool}{CanCut}{\void}
150
151Returns true if the combobox is editable and there is a text selection to copy to the clipboard.
152Only available on Windows.
153
3782aa47 154
150e31d2
JS
155\membersection{wxComboBox::CanPaste}\label{wxcomboboxcanpaste}
156
157\constfunc{bool}{CanPaste}{\void}
158
159Returns true if the combobox is editable and there is text on the clipboard that can be pasted into the
160text field. Only available on Windows.
161
3782aa47 162
150e31d2
JS
163\membersection{wxComboBox::CanRedo}\label{wxcomboboxcanredo}
164
165\constfunc{bool}{CanRedo}{\void}
166
167Returns true if the combobox is editable and the last undo can be redone.
168Only available on Windows.
7d8268a1 169
3782aa47 170
150e31d2
JS
171\membersection{wxComboBox::CanUndo}\label{wxcomboboxcanundo}
172
173\constfunc{bool}{CanUndo}{\void}
174
175Returns true if the combobox is editable and the last edit can be undone.
176Only available on Windows.
7d8268a1 177
3782aa47 178
a660d684
KB
179\membersection{wxComboBox::Copy}\label{wxcomboboxcopy}
180
181\func{void}{Copy}{\void}
182
183Copies the selected text to the clipboard.
184
3782aa47 185
a660d684
KB
186\membersection{wxComboBox::Cut}\label{wxcomboboxcut}
187
188\func{void}{Cut}{\void}
189
190Copies the selected text to the clipboard and removes the selection.
191
3782aa47 192
a660d684
KB
193\membersection{wxComboBox::GetInsertionPoint}\label{wxcomboboxgetinsertionpoint}
194
195\constfunc{long}{GetInsertionPoint}{\void}
196
197Returns the insertion point for the combobox's text field.
198
3782aa47
VZ
199\textbf{Note:} Under wxMSW, this function always returns $0$ if the combobox
200doesn't have the focus.
201
202
a660d684
KB
203\membersection{wxComboBox::GetLastPosition}\label{wxcomboboxgetlastposition}
204
7d8268a1 205\constfunc{virtual wxTextPos}{GetLastPosition}{\void}
a660d684
KB
206
207Returns the last position in the combobox text field.
208
3782aa47 209
a660d684
KB
210\membersection{wxComboBox::GetValue}\label{wxcomboboxgetvalue}
211
212\constfunc{wxString}{GetValue}{\void}
213
214Returns the current value in the combobox text field.
215
3782aa47 216
a660d684
KB
217\membersection{wxComboBox::Paste}\label{wxcomboboxpaste}
218
219\func{void}{Paste}{\void}
220
221Pastes text from the clipboard to the text field.
222
3782aa47 223
150e31d2
JS
224\membersection{wxComboBox::Redo}\label{wxcomboboxredo}
225
226\func{void}{Redo}{\void}
227
228Redoes the last undo in the text field. Windows only.
229
3782aa47 230
a660d684
KB
231\membersection{wxComboBox::Replace}\label{wxcomboboxreplace}
232
eaaa6a06 233\func{void}{Replace}{\param{long}{ from}, \param{long}{ to}, \param{const wxString\& }{text}}
a660d684
KB
234
235Replaces the text between two positions with the given text, in the combobox text field.
236
237\wxheading{Parameters}
238
239\docparam{from}{The first position.}
240
241\docparam{to}{The second position.}
242
243\docparam{text}{The text to insert.}
244
3782aa47 245
a660d684
KB
246\membersection{wxComboBox::Remove}\label{wxcomboboxremove}
247
eaaa6a06 248\func{void}{Remove}{\param{long}{ from}, \param{long}{ to}}
a660d684
KB
249
250Removes the text between the two positions in the combobox text field.
251
252\wxheading{Parameters}
253
254\docparam{from}{The first position.}
255
256\docparam{to}{The last position.}
257
3782aa47 258
a660d684
KB
259\membersection{wxComboBox::SetInsertionPoint}\label{wxcomboboxsetinsertionpoint}
260
eaaa6a06 261\func{void}{SetInsertionPoint}{\param{long}{ pos}}
a660d684
KB
262
263Sets the insertion point in the combobox text field.
264
265\wxheading{Parameters}
266
267\docparam{pos}{The new insertion point.}
268
3782aa47 269
a660d684
KB
270\membersection{wxComboBox::SetInsertionPointEnd}\label{wxcomboboxsetinsertionpointend}
271
272\func{void}{SetInsertionPointEnd}{\void}
273
274Sets the insertion point at the end of the combobox text field.
275
3782aa47 276
a660d684
KB
277\membersection{wxComboBox::SetSelection}\label{wxcomboboxsetselection}
278
eaaa6a06 279\func{void}{SetSelection}{\param{long}{ from}, \param{long}{ to}}
a660d684
KB
280
281Selects the text between the two positions, in the combobox text field.
282
283\wxheading{Parameters}
284
a660d684
KB
285\docparam{from}{The first position.}
286
287\docparam{to}{The second position.}
288
bed5584e 289\pythonnote{This method is called {\tt SetMark} in wxPython, {\tt SetSelection}
7d8268a1 290name is kept for
bed5584e 291\helpref{wxControlWithItems::SetSelection}{wxcontrolwithitemssetselection}.}
532da0d1 292
3782aa47 293
a660d684
KB
294\membersection{wxComboBox::SetValue}\label{wxcomboboxsetvalue}
295
296\func{void}{SetValue}{\param{const wxString\& }{text}}
297
298Sets the text for the combobox text field.
299
3ca6a5f0
BP
300{\bf NB:} For a combobox with {\tt wxCB\_READONLY} style the string must be in
301the combobox choices list, otherwise the call to SetValue() is ignored.
302
a660d684
KB
303\wxheading{Parameters}
304
305\docparam{text}{The text to set.}
306
3782aa47 307
150e31d2
JS
308\membersection{wxComboBox::Undo}\label{wxcomboboxundo}
309
310\func{void}{Undo}{\void}
311
312Undoes the last edit in the text field. Windows only.
a660d684 313