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.
}
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
27 displaying the current selection.
}
28 \twocolitem{\windowstyle{wxCB
\_SORT}}{Sorts the entries in the list alphabetically.
}
31 See also
\helpref{window styles overview
}{windowstyles
}.
33 \wxheading{Event handling
}
36 \begin{twocollist
}\itemsep=
0pt
37 \twocolitem{{\bf EVT
\_COMBOBOX(id, func)
}}{Process a wxEVT
\_COMMAND\_COMBOBOX\_SELECTED event,
38 when an item on the list is selected.
}
39 \twocolitem{{\bf EVT
\_TEXT(id, func)
}}{Process a wxEVT
\_COMMAND\_TEXT\_UPDATED event,
40 when the combobox text changes.
}
45 \helpref{wxListBox
}{wxlistbox
},
\helpref{wxTextCtrl
}{wxtextctrl
},
\helpref{wxChoice
}{wxchoice
},
46 \rtfsp\helpref{wxCommandEvent
}{wxcommandevent
}
48 \latexignore{\rtfignore{\wxheading{Members
}}}
50 \membersection{wxComboBox::wxComboBox
}\label{wxcomboboxconstr
}
52 \func{}{wxComboBox
}{\void}
56 \func{}{wxComboBox
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
57 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
58 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
59 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
61 Constructor, creating and showing a combobox.
63 \wxheading{Parameters
}
65 \docparam{parent
}{Parent window. Must not be NULL.
}
67 \docparam{id
}{Window identifier. A value of -
1 indicates a default value.
}
69 \docparam{pos
}{Window position.
}
71 \docparam{size
}{Window size. If the default size (-
1, -
1) is specified then the window is sized
74 \docparam{n
}{Number of strings with which to initialise the control.
}
76 \docparam{choices
}{An array of strings with which to initialise the control.
}
78 \docparam{style
}{Window style. See
\helpref{wxComboBox
}{wxcombobox
}.
}
80 \docparam{validator
}{Window validator.
}
82 \docparam{name
}{Window name.
}
86 \helpref{wxComboBox::Create
}{wxcomboboxcreate
},
\helpref{wxValidator
}{wxvalidator
}
88 \membersection{wxComboBox::
\destruct{wxComboBox
}}
90 \func{}{\destruct{wxComboBox
}}{\void}
92 Destructor, destroying the combobox.
94 \membersection{wxComboBox::Append
}\label{wxcomboboxappend
}
96 \func{void
}{Append
}{\param{const wxString\&
}{item
}}
98 Adds the item to the end of the combobox.
100 \func{void
}{Append
}{\param{const wxString\&
}{ item
},
\param{char*
}{clientData
}}
102 Adds the item to the end of the combobox, associating the given data
105 \wxheading{Parameters
}
107 \docparam{item
}{The string to add.
}
109 \docparam{clientData
}{Client data to associate with the item.
}
111 \membersection{wxComboBox::Clear
}\label{wxcomboboxclear
}
113 \func{void
}{Clear
}{\void}
115 Clears all strings from the combobox.
117 \membersection{wxComboBox::Create
}\label{wxcomboboxcreate
}
119 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
120 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
121 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
122 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
124 Creates the combobox for two-step construction. Derived classes
125 should call or replace this function. See
\helpref{wxComboBox::wxComboBox
}{wxcomboboxconstr
}\rtfsp
128 \membersection{wxComboBox::Copy
}\label{wxcomboboxcopy
}
130 \func{void
}{Copy
}{\void}
132 Copies the selected text to the clipboard.
134 \membersection{wxComboBox::Cut
}\label{wxcomboboxcut
}
136 \func{void
}{Cut
}{\void}
138 Copies the selected text to the clipboard and removes the selection.
140 \membersection{wxComboBox::Delete
}\label{wxcomboboxdelete
}
142 \func{void
}{Delete
}{\param{int
}{ n
}}
144 Deletes an item from the combobox.
146 \wxheading{Parameters
}
148 \docparam{n
}{The item to delete, starting from zero.
}
150 \membersection{wxComboBox::FindString
}\label{wxcomboboxfindstring
}
152 \func{int
}{FindString
}{\param{const wxString\&
}{string
}}
154 Finds a choice matching the given string.
156 \wxheading{Parameters
}
158 \docparam{string
}{The item to find.
}
160 \wxheading{Return value
}
162 The position if found, or -
1 if not found.
164 \membersection{wxComboBox::GetClientData
}\label{wxcomboboxgetclientdata
}
166 \constfunc{char*
}{GetClientData
}{\param{int
}{ n
}}
168 Returns a pointer to the client data associated with the given item (if any).
170 \wxheading{Parameters
}
172 \docparam{n
}{An item, starting from zero.
}
174 \wxheading{Return value
}
176 A pointer to the client data, or NULL if the item was not found.
178 \membersection{wxComboBox::GetInsertionPoint
}\label{wxcomboboxgetinsertionpoint
}
180 \constfunc{long
}{GetInsertionPoint
}{\void}
182 Returns the insertion point for the combobox's text field.
184 \membersection{wxComboBox::GetLastPosition
}\label{wxcomboboxgetlastposition
}
186 \constfunc{long
}{GetLastPosition
}{\void}
188 Returns the last position in the combobox text field.
190 \membersection{wxComboBox::GetSelection
}\label{wxcomboboxgetselection
}
192 \constfunc{int
}{GetSelection
}{\void}
194 Gets the position of the selected string, or -
1 if there is no selection.
196 \membersection{wxComboBox::GetString
}\label{wxcomboboxgetstring
}
198 \constfunc{wxString
}{GetString
}{\param{int
}{ n
}}
200 Returns the string at position
{\it n
}.
202 \wxheading{Parameters
}
204 \docparam{n
}{The item position, starting from zero.
}
206 \wxheading{Return value
}
208 The string if the item is found, otherwise the empty string.
210 \membersection{wxComboBox::GetStringSelection
}\label{wxcomboboxgetstringselection
}
212 \constfunc{wxString
}{GetStringSelection
}{\void}
214 Gets the selected string.
216 \membersection{wxComboBox::GetValue
}\label{wxcomboboxgetvalue
}
218 \constfunc{wxString
}{GetValue
}{\void}
220 Returns the current value in the combobox text field.
222 \membersection{wxComboBox::Number
}\label{wxcomboboxnumber
}
224 \constfunc{int
}{Number
}{\void}
226 Returns the number of items in the combobox list.
227 %TODO: make this GetNumber or GetCount?
229 \membersection{wxComboBox::Paste
}\label{wxcomboboxpaste
}
231 \func{void
}{Paste
}{\void}
233 Pastes text from the clipboard to the text field.
235 \membersection{wxComboBox::Replace
}\label{wxcomboboxreplace
}
237 \func{void
}{Replace
}{\param{long
}{ from
},
\param{long
}{ to
},
\param{const wxString\&
}{text
}}
239 Replaces the text between two positions with the given text, in the combobox text field.
241 \wxheading{Parameters
}
243 \docparam{from
}{The first position.
}
245 \docparam{to
}{The second position.
}
247 \docparam{text
}{The text to insert.
}
249 \membersection{wxComboBox::Remove
}\label{wxcomboboxremove
}
251 \func{void
}{Remove
}{\param{long
}{ from
},
\param{long
}{ to
}}
253 Removes the text between the two positions in the combobox text field.
255 \wxheading{Parameters
}
257 \docparam{from
}{The first position.
}
259 \docparam{to
}{The last position.
}
261 \membersection{wxComboBox::SetClientData
}\label{wxcomboboxsetclientdata
}
263 \func{void
}{SetClientData
}{\param{int
}{ n
},
\param{char*
}{data
}}
265 Associates the given client data pointer with the given item.
267 \wxheading{Parameters
}
269 \docparam{n
}{The zero-based item.
}
271 \docparam{data
}{The client data.
}
273 \membersection{wxComboBox::SetInsertionPoint
}\label{wxcomboboxsetinsertionpoint
}
275 \func{void
}{SetInsertionPoint
}{\param{long
}{ pos
}}
277 Sets the insertion point in the combobox text field.
279 \wxheading{Parameters
}
281 \docparam{pos
}{The new insertion point.
}
283 \membersection{wxComboBox::SetInsertionPointEnd
}\label{wxcomboboxsetinsertionpointend
}
285 \func{void
}{SetInsertionPointEnd
}{\void}
287 Sets the insertion point at the end of the combobox text field.
289 \membersection{wxComboBox::SetSelection
}\label{wxcomboboxsetselection
}
291 \func{void
}{SetSelection
}{\param{int
}{ n
}}
293 Selects the given item in the combobox list.
295 \func{void
}{SetSelection
}{\param{long
}{ from
},
\param{long
}{ to
}}
297 Selects the text between the two positions, in the combobox text field.
299 \wxheading{Parameters
}
301 \docparam{n
}{The zero-based item to select.
}
303 \docparam{from
}{The first position.
}
305 \docparam{to
}{The second position.
}
307 \membersection{wxComboBox::SetValue
}\label{wxcomboboxsetvalue
}
309 \func{void
}{SetValue
}{\param{const wxString\&
}{text
}}
311 Sets the text for the combobox text field.
313 \wxheading{Parameters
}
315 \docparam{text
}{The text to set.
}