]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/combobox.tex
* Stream doc.
[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
17\wxheading{Window styles}
18
19\begin{twocollist}\itemsep=0pt
20\twocolitem{\windowstyle{wxCB\_SIMPLE}}{Creates a combobox with a permanently displayed list.}
21\twocolitem{\windowstyle{wxCB\_DROPDOWN}}{Creates a combobox with a drop-down list.}
22\twocolitem{\windowstyle{wxCB\_READONLY}}{Creates a combo box consisting of a drop-down list and static text item
23displaying the current selection.}
24\twocolitem{\windowstyle{wxCB\_SORT}}{Sorts the entries in the list alphabetically.}
25\end{twocollist}
26
27See also \helpref{window styles overview}{windowstyles}.
28
5de76427
JS
29\wxheading{Event handling}
30
31\twocolwidtha{7cm}
32\begin{twocollist}\itemsep=0pt
33\twocolitem{{\bf EVT\_COMBOBOX(id, func)}}{Process a wxEVT\_COMMAND\_COMBOBOX\_SELECTED event,
34when an item on the list is selected.}
35\twocolitem{{\bf EVT\_TEXT(id, func)}}{Process a wxEVT\_COMMAND\_TEXT\_UPDATED event,
36when the combobox text changes.}
37\end{twocollist}
38
a660d684
KB
39\wxheading{See also}
40
5de76427
JS
41\helpref{wxListBox}{wxlistbox}, \helpref{wxTextCtrl}{wxtextctrl}, \helpref{wxChoice}{wxchoice},
42\rtfsp\helpref{wxCommandEvent}{wxcommandevent}
a660d684
KB
43
44\latexignore{\rtfignore{\wxheading{Members}}}
45
46\membersection{wxComboBox::wxComboBox}\label{wxcomboboxconstr}
47
48\func{}{wxComboBox}{\void}
49
50Default constructor.
51
eaaa6a06 52\func{}{wxComboBox}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
a660d684 53\param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
eaaa6a06
JS
54\param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
55\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
a660d684
KB
56
57Constructor, creating and showing a combobox.
58
59\wxheading{Parameters}
60
61\docparam{parent}{Parent window. Must not be NULL.}
62
63\docparam{id}{Window identifier. A value of -1 indicates a default value.}
64
65\docparam{pos}{Window position.}
66
67\docparam{size}{Window size. If the default size (-1, -1) is specified then the window is sized
68appropriately.}
69
70\docparam{n}{Number of strings with which to initialise the control.}
71
72\docparam{choices}{An array of strings with which to initialise the control.}
73
74\docparam{style}{Window style. See \helpref{wxComboBox}{wxcombobox}.}
75
76\docparam{validator}{Window validator.}
77
78\docparam{name}{Window name.}
79
80\wxheading{See also}
81
82\helpref{wxComboBox::Create}{wxcomboboxcreate}, \helpref{wxValidator}{wxvalidator}
83
84\membersection{wxComboBox::\destruct{wxComboBox}}
85
86\func{}{\destruct{wxComboBox}}{\void}
87
88Destructor, destroying the combobox.
89
90\membersection{wxComboBox::Append}\label{wxcomboboxappend}
91
92\func{void}{Append}{\param{const wxString\& }{item}}
93
94Adds the item to the end of the combobox.
95
96\func{void}{Append}{\param{const wxString\& }{ item}, \param{char* }{clientData}}
97
98Adds the item to the end of the combobox, associating the given data
99with the item.
100
101\wxheading{Parameters}
102
103\docparam{item}{The string to add.}
104
105\docparam{clientData}{Client data to associate with the item.}
106
107\membersection{wxComboBox::Clear}\label{wxcomboboxclear}
108
109\func{void}{Clear}{\void}
110
111Clears all strings from the combobox.
112
113\membersection{wxComboBox::Create}\label{wxcomboboxcreate}
114
eaaa6a06 115\func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
a660d684 116\param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
eaaa6a06
JS
117\param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
118\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
a660d684
KB
119
120Creates the combobox for two-step construction. Derived classes
121should call or replace this function. See \helpref{wxComboBox::wxComboBox}{wxcomboboxconstr}\rtfsp
122for further details.
123
124\membersection{wxComboBox::Copy}\label{wxcomboboxcopy}
125
126\func{void}{Copy}{\void}
127
128Copies the selected text to the clipboard.
129
130\membersection{wxComboBox::Cut}\label{wxcomboboxcut}
131
132\func{void}{Cut}{\void}
133
134Copies the selected text to the clipboard and removes the selection.
135
136\membersection{wxComboBox::Delete}\label{wxcomboboxdelete}
137
eaaa6a06 138\func{void}{Delete}{\param{int}{ n}}
a660d684
KB
139
140Deletes an item from the combobox.
141
142\wxheading{Parameters}
143
144\docparam{n}{The item to delete, starting from zero.}
145
a660d684
KB
146\membersection{wxComboBox::FindString}\label{wxcomboboxfindstring}
147
148\func{int}{FindString}{\param{const wxString\& }{string}}
149
150Finds a choice matching the given string.
151
152\wxheading{Parameters}
153
154\docparam{string}{The item to find.}
155
156\wxheading{Return value}
157
158The position if found, or -1 if not found.
159
160\membersection{wxComboBox::GetClientData}\label{wxcomboboxgetclientdata}
161
eaaa6a06 162\constfunc{char*}{GetClientData}{\param{int}{ n}}
a660d684
KB
163
164Returns a pointer to the client data associated with the given item (if any).
165
166\wxheading{Parameters}
167
168\docparam{n}{An item, starting from zero.}
169
170\wxheading{Return value}
171
172A pointer to the client data, or NULL if the item was not found.
173
174\membersection{wxComboBox::GetInsertionPoint}\label{wxcomboboxgetinsertionpoint}
175
176\constfunc{long}{GetInsertionPoint}{\void}
177
178Returns the insertion point for the combobox's text field.
179
180\membersection{wxComboBox::GetLastPosition}\label{wxcomboboxgetlastposition}
181
182\constfunc{long}{GetLastPosition}{\void}
183
184Returns the last position in the combobox text field.
185
186\membersection{wxComboBox::GetSelection}\label{wxcomboboxgetselection}
187
188\constfunc{int}{GetSelection}{\void}
189
190Gets the position of the selected string, or -1 if there is no selection.
191
192\membersection{wxComboBox::GetString}\label{wxcomboboxgetstring}
193
194\constfunc{wxString}{GetString}{\param{int}{ n}}
195
196Returns the string at position {\it n}.
197
198\wxheading{Parameters}
199
200\docparam{n}{The item position, starting from zero.}
201
202\wxheading{Return value}
203
204The string if the item is found, otherwise the empty string.
205
206\membersection{wxComboBox::GetStringSelection}\label{wxcomboboxgetstringselection}
207
208\constfunc{wxString}{GetStringSelection}{\void}
209
210Gets the selected string.
211
212\membersection{wxComboBox::GetValue}\label{wxcomboboxgetvalue}
213
214\constfunc{wxString}{GetValue}{\void}
215
216Returns the current value in the combobox text field.
217
218\membersection{wxComboBox::Number}\label{wxcomboboxnumber}
219
220\constfunc{int}{Number}{\void}
221
222Returns the number of items in the combobox list.
5b6aa0ff 223%TODO: make this GetNumber or GetCount?
a660d684
KB
224
225\membersection{wxComboBox::Paste}\label{wxcomboboxpaste}
226
227\func{void}{Paste}{\void}
228
229Pastes text from the clipboard to the text field.
230
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
245\membersection{wxComboBox::Remove}\label{wxcomboboxremove}
246
eaaa6a06 247\func{void}{Remove}{\param{long}{ from}, \param{long}{ to}}
a660d684
KB
248
249Removes the text between the two positions in the combobox text field.
250
251\wxheading{Parameters}
252
253\docparam{from}{The first position.}
254
255\docparam{to}{The last position.}
256
257\membersection{wxComboBox::SetClientData}\label{wxcomboboxsetclientdata}
258
eaaa6a06 259\func{void}{SetClientData}{\param{int}{ n}, \param{char* }{data}}
a660d684
KB
260
261Associates the given client data pointer with the given item.
262
263\wxheading{Parameters}
264
265\docparam{n}{The zero-based item.}
266
267\docparam{data}{The client data.}
268
269\membersection{wxComboBox::SetInsertionPoint}\label{wxcomboboxsetinsertionpoint}
270
eaaa6a06 271\func{void}{SetInsertionPoint}{\param{long}{ pos}}
a660d684
KB
272
273Sets the insertion point in the combobox text field.
274
275\wxheading{Parameters}
276
277\docparam{pos}{The new insertion point.}
278
279\membersection{wxComboBox::SetInsertionPointEnd}\label{wxcomboboxsetinsertionpointend}
280
281\func{void}{SetInsertionPointEnd}{\void}
282
283Sets the insertion point at the end of the combobox text field.
284
285\membersection{wxComboBox::SetSelection}\label{wxcomboboxsetselection}
286
eaaa6a06 287\func{void}{SetSelection}{\param{int}{ n}}
a660d684
KB
288
289Selects the given item in the combobox list.
290
eaaa6a06 291\func{void}{SetSelection}{\param{long}{ from}, \param{long}{ to}}
a660d684
KB
292
293Selects the text between the two positions, in the combobox text field.
294
295\wxheading{Parameters}
296
297\docparam{n}{The zero-based item to select.}
298
299\docparam{from}{The first position.}
300
301\docparam{to}{The second position.}
302
303\membersection{wxComboBox::SetValue}\label{wxcomboboxsetvalue}
304
305\func{void}{SetValue}{\param{const wxString\& }{text}}
306
307Sets the text for the combobox text field.
308
309\wxheading{Parameters}
310
311\docparam{text}{The text to set.}
312
313