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{Window styles
}
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
23 displaying the current selection.
}
24 \twocolitem{\windowstyle{wxCB
\_SORT}}{Sorts the entries in the list alphabetically.
}
27 See also
\helpref{window styles overview
}{windowstyles
}.
29 \wxheading{Event handling
}
32 \begin{twocollist
}\itemsep=
0pt
33 \twocolitem{{\bf EVT
\_COMBOBOX(id, func)
}}{Process a wxEVT
\_COMMAND\_COMBOBOX\_SELECTED event,
34 when an item on the list is selected.
}
35 \twocolitem{{\bf EVT
\_TEXT(id, func)
}}{Process a wxEVT
\_COMMAND\_TEXT\_UPDATED event,
36 when the combobox text changes.
}
41 \helpref{wxListBox
}{wxlistbox
},
\helpref{wxTextCtrl
}{wxtextctrl
},
\helpref{wxChoice
}{wxchoice
},
42 \rtfsp\helpref{wxCommandEvent
}{wxcommandevent
}
44 \latexignore{\rtfignore{\wxheading{Members
}}}
46 \membersection{wxComboBox::wxComboBox
}\label{wxcomboboxconstr
}
48 \func{}{wxComboBox
}{\void}
52 \func{}{wxComboBox
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
53 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
54 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
55 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
57 Constructor, creating and showing a combobox.
59 \wxheading{Parameters
}
61 \docparam{parent
}{Parent window. Must not be NULL.
}
63 \docparam{id
}{Window identifier. A value of -
1 indicates a default value.
}
65 \docparam{pos
}{Window position.
}
67 \docparam{size
}{Window size. If the default size (-
1, -
1) is specified then the window is sized
70 \docparam{n
}{Number of strings with which to initialise the control.
}
72 \docparam{choices
}{An array of strings with which to initialise the control.
}
74 \docparam{style
}{Window style. See
\helpref{wxComboBox
}{wxcombobox
}.
}
76 \docparam{validator
}{Window validator.
}
78 \docparam{name
}{Window name.
}
82 \helpref{wxComboBox::Create
}{wxcomboboxcreate
},
\helpref{wxValidator
}{wxvalidator
}
84 \membersection{wxComboBox::
\destruct{wxComboBox
}}
86 \func{}{\destruct{wxComboBox
}}{\void}
88 Destructor, destroying the combobox.
90 \membersection{wxComboBox::Append
}\label{wxcomboboxappend
}
92 \func{void
}{Append
}{\param{const wxString\&
}{item
}}
94 Adds the item to the end of the combobox.
96 \func{void
}{Append
}{\param{const wxString\&
}{ item
},
\param{char*
}{clientData
}}
98 Adds the item to the end of the combobox, associating the given data
101 \wxheading{Parameters
}
103 \docparam{item
}{The string to add.
}
105 \docparam{clientData
}{Client data to associate with the item.
}
107 \membersection{wxComboBox::Clear
}\label{wxcomboboxclear
}
109 \func{void
}{Clear
}{\void}
111 Clears all strings from the combobox.
113 \membersection{wxComboBox::Create
}\label{wxcomboboxcreate
}
115 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
116 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
117 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
118 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
120 Creates the combobox for two-step construction. Derived classes
121 should call or replace this function. See
\helpref{wxComboBox::wxComboBox
}{wxcomboboxconstr
}\rtfsp
124 \membersection{wxComboBox::Copy
}\label{wxcomboboxcopy
}
126 \func{void
}{Copy
}{\void}
128 Copies the selected text to the clipboard.
130 \membersection{wxComboBox::Cut
}\label{wxcomboboxcut
}
132 \func{void
}{Cut
}{\void}
134 Copies the selected text to the clipboard and removes the selection.
136 \membersection{wxComboBox::Delete
}\label{wxcomboboxdelete
}
138 \func{void
}{Delete
}{\param{int
}{ n
}}
140 Deletes an item from the combobox.
142 \wxheading{Parameters
}
144 \docparam{n
}{The item to delete, starting from zero.
}
146 \membersection{wxComboBox::FindString
}\label{wxcomboboxfindstring
}
148 \func{int
}{FindString
}{\param{const wxString\&
}{string
}}
150 Finds a choice matching the given string.
152 \wxheading{Parameters
}
154 \docparam{string
}{The item to find.
}
156 \wxheading{Return value
}
158 The position if found, or -
1 if not found.
160 \membersection{wxComboBox::GetClientData
}\label{wxcomboboxgetclientdata
}
162 \constfunc{char*
}{GetClientData
}{\param{int
}{ n
}}
164 Returns a pointer to the client data associated with the given item (if any).
166 \wxheading{Parameters
}
168 \docparam{n
}{An item, starting from zero.
}
170 \wxheading{Return value
}
172 A pointer to the client data, or NULL if the item was not found.
174 \membersection{wxComboBox::GetInsertionPoint
}\label{wxcomboboxgetinsertionpoint
}
176 \constfunc{long
}{GetInsertionPoint
}{\void}
178 Returns the insertion point for the combobox's text field.
180 \membersection{wxComboBox::GetLastPosition
}\label{wxcomboboxgetlastposition
}
182 \constfunc{long
}{GetLastPosition
}{\void}
184 Returns the last position in the combobox text field.
186 \membersection{wxComboBox::GetSelection
}\label{wxcomboboxgetselection
}
188 \constfunc{int
}{GetSelection
}{\void}
190 Gets the position of the selected string, or -
1 if there is no selection.
192 \membersection{wxComboBox::GetString
}\label{wxcomboboxgetstring
}
194 \constfunc{wxString
}{GetString
}{\param{int
}{ n
}}
196 Returns the string at position
{\it n
}.
198 \wxheading{Parameters
}
200 \docparam{n
}{The item position, starting from zero.
}
202 \wxheading{Return value
}
204 The string if the item is found, otherwise the empty string.
206 \membersection{wxComboBox::GetStringSelection
}\label{wxcomboboxgetstringselection
}
208 \constfunc{wxString
}{GetStringSelection
}{\void}
210 Gets the selected string.
212 \membersection{wxComboBox::GetValue
}\label{wxcomboboxgetvalue
}
214 \constfunc{wxString
}{GetValue
}{\void}
216 Returns the current value in the combobox text field.
218 \membersection{wxComboBox::Number
}\label{wxcomboboxnumber
}
220 \constfunc{int
}{Number
}{\void}
222 Returns the number of items in the combobox list.
224 TODO: make this GetNumber or GetCount?
226 \membersection{wxComboBox::Paste
}\label{wxcomboboxpaste
}
228 \func{void
}{Paste
}{\void}
230 Pastes text from the clipboard to the text field.
232 \membersection{wxComboBox::Replace
}\label{wxcomboboxreplace
}
234 \func{void
}{Replace
}{\param{long
}{ from
},
\param{long
}{ to
},
\param{const wxString\&
}{text
}}
236 Replaces the text between two positions with the given text, in the combobox text field.
238 \wxheading{Parameters
}
240 \docparam{from
}{The first position.
}
242 \docparam{to
}{The second position.
}
244 \docparam{text
}{The text to insert.
}
246 \membersection{wxComboBox::Remove
}\label{wxcomboboxremove
}
248 \func{void
}{Remove
}{\param{long
}{ from
},
\param{long
}{ to
}}
250 Removes the text between the two positions in the combobox text field.
252 \wxheading{Parameters
}
254 \docparam{from
}{The first position.
}
256 \docparam{to
}{The last position.
}
258 \membersection{wxComboBox::SetClientData
}\label{wxcomboboxsetclientdata
}
260 \func{void
}{SetClientData
}{\param{int
}{ n
},
\param{char*
}{data
}}
262 Associates the given client data pointer with the given item.
264 \wxheading{Parameters
}
266 \docparam{n
}{The zero-based item.
}
268 \docparam{data
}{The client data.
}
270 \membersection{wxComboBox::SetInsertionPoint
}\label{wxcomboboxsetinsertionpoint
}
272 \func{void
}{SetInsertionPoint
}{\param{long
}{ pos
}}
274 Sets the insertion point in the combobox text field.
276 \wxheading{Parameters
}
278 \docparam{pos
}{The new insertion point.
}
280 \membersection{wxComboBox::SetInsertionPointEnd
}\label{wxcomboboxsetinsertionpointend
}
282 \func{void
}{SetInsertionPointEnd
}{\void}
284 Sets the insertion point at the end of the combobox text field.
286 \membersection{wxComboBox::SetSelection
}\label{wxcomboboxsetselection
}
288 \func{void
}{SetSelection
}{\param{int
}{ n
}}
290 Selects the given item in the combobox list.
292 \func{void
}{SetSelection
}{\param{long
}{ from
},
\param{long
}{ to
}}
294 Selects the text between the two positions, in the combobox text field.
296 \wxheading{Parameters
}
298 \docparam{n
}{The zero-based item to select.
}
300 \docparam{from
}{The first position.
}
302 \docparam{to
}{The second position.
}
304 \membersection{wxComboBox::SetValue
}\label{wxcomboboxsetvalue
}
306 \func{void
}{SetValue
}{\param{const wxString\&
}{text
}}
308 Sets the text for the combobox text field.
310 \wxheading{Parameters
}
312 \docparam{text
}{The text to set.
}