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