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
}.
31 \helpref{wxListBox
}{wxlistbox
},
\helpref{wxTextCtrl
}{wxtextctrl
},
\helpref{wxChoice
}{wxchoice
}
33 \latexignore{\rtfignore{\wxheading{Members
}}}
35 \membersection{wxComboBox::wxComboBox
}\label{wxcomboboxconstr
}
37 \func{}{wxComboBox
}{\void}
41 \func{}{wxComboBox
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
42 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
43 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
44 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
46 Constructor, creating and showing a combobox.
48 \wxheading{Parameters
}
50 \docparam{parent
}{Parent window. Must not be NULL.
}
52 \docparam{id
}{Window identifier. A value of -
1 indicates a default value.
}
54 \docparam{pos
}{Window position.
}
56 \docparam{size
}{Window size. If the default size (-
1, -
1) is specified then the window is sized
59 \docparam{n
}{Number of strings with which to initialise the control.
}
61 \docparam{choices
}{An array of strings with which to initialise the control.
}
63 \docparam{style
}{Window style. See
\helpref{wxComboBox
}{wxcombobox
}.
}
65 \docparam{validator
}{Window validator.
}
67 \docparam{name
}{Window name.
}
71 \helpref{wxComboBox::Create
}{wxcomboboxcreate
},
\helpref{wxValidator
}{wxvalidator
}
73 \membersection{wxComboBox::
\destruct{wxComboBox
}}
75 \func{}{\destruct{wxComboBox
}}{\void}
77 Destructor, destroying the combobox.
79 \membersection{wxComboBox::Append
}\label{wxcomboboxappend
}
81 \func{void
}{Append
}{\param{const wxString\&
}{item
}}
83 Adds the item to the end of the combobox.
85 \func{void
}{Append
}{\param{const wxString\&
}{ item
},
\param{char*
}{clientData
}}
87 Adds the item to the end of the combobox, associating the given data
90 \wxheading{Parameters
}
92 \docparam{item
}{The string to add.
}
94 \docparam{clientData
}{Client data to associate with the item.
}
96 \membersection{wxComboBox::Clear
}\label{wxcomboboxclear
}
98 \func{void
}{Clear
}{\void}
100 Clears all strings from the combobox.
102 \membersection{wxComboBox::Create
}\label{wxcomboboxcreate
}
104 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
105 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
106 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
107 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
109 Creates the combobox for two-step construction. Derived classes
110 should call or replace this function. See
\helpref{wxComboBox::wxComboBox
}{wxcomboboxconstr
}\rtfsp
113 \membersection{wxComboBox::Copy
}\label{wxcomboboxcopy
}
115 \func{void
}{Copy
}{\void}
117 Copies the selected text to the clipboard.
119 \membersection{wxComboBox::Cut
}\label{wxcomboboxcut
}
121 \func{void
}{Cut
}{\void}
123 Copies the selected text to the clipboard and removes the selection.
125 \membersection{wxComboBox::Delete
}\label{wxcomboboxdelete
}
127 \func{void
}{Delete
}{\param{int
}{ n
}}
129 Deletes an item from the combobox.
131 \wxheading{Parameters
}
133 \docparam{n
}{The item to delete, starting from zero.
}
135 \membersection{wxComboBox::FindString
}\label{wxcomboboxfindstring
}
137 \func{int
}{FindString
}{\param{const wxString\&
}{string
}}
139 Finds a choice matching the given string.
141 \wxheading{Parameters
}
143 \docparam{string
}{The item to find.
}
145 \wxheading{Return value
}
147 The position if found, or -
1 if not found.
149 \membersection{wxComboBox::GetClientData
}\label{wxcomboboxgetclientdata
}
151 \constfunc{char*
}{GetClientData
}{\param{int
}{ n
}}
153 Returns a pointer to the client data associated with the given item (if any).
155 \wxheading{Parameters
}
157 \docparam{n
}{An item, starting from zero.
}
159 \wxheading{Return value
}
161 A pointer to the client data, or NULL if the item was not found.
163 \membersection{wxComboBox::GetInsertionPoint
}\label{wxcomboboxgetinsertionpoint
}
165 \constfunc{long
}{GetInsertionPoint
}{\void}
167 Returns the insertion point for the combobox's text field.
169 \membersection{wxComboBox::GetLastPosition
}\label{wxcomboboxgetlastposition
}
171 \constfunc{long
}{GetLastPosition
}{\void}
173 Returns the last position in the combobox text field.
175 \membersection{wxComboBox::GetSelection
}\label{wxcomboboxgetselection
}
177 \constfunc{int
}{GetSelection
}{\void}
179 Gets the position of the selected string, or -
1 if there is no selection.
181 \membersection{wxComboBox::GetString
}\label{wxcomboboxgetstring
}
183 \constfunc{wxString
}{GetString
}{\param{int
}{ n
}}
185 Returns the string at position
{\it n
}.
187 \wxheading{Parameters
}
189 \docparam{n
}{The item position, starting from zero.
}
191 \wxheading{Return value
}
193 The string if the item is found, otherwise the empty string.
195 \membersection{wxComboBox::GetStringSelection
}\label{wxcomboboxgetstringselection
}
197 \constfunc{wxString
}{GetStringSelection
}{\void}
199 Gets the selected string.
201 \membersection{wxComboBox::GetValue
}\label{wxcomboboxgetvalue
}
203 \constfunc{wxString
}{GetValue
}{\void}
205 Returns the current value in the combobox text field.
207 \membersection{wxComboBox::Number
}\label{wxcomboboxnumber
}
209 \constfunc{int
}{Number
}{\void}
211 Returns the number of items in the combobox list.
213 TODO: make this GetNumber or GetCount?
215 \membersection{wxComboBox::Paste
}\label{wxcomboboxpaste
}
217 \func{void
}{Paste
}{\void}
219 Pastes text from the clipboard to the text field.
221 \membersection{wxComboBox::Replace
}\label{wxcomboboxreplace
}
223 \func{void
}{Replace
}{\param{long
}{ from
},
\param{long
}{ to
},
\param{const wxString\&
}{text
}}
225 Replaces the text between two positions with the given text, in the combobox text field.
227 \wxheading{Parameters
}
229 \docparam{from
}{The first position.
}
231 \docparam{to
}{The second position.
}
233 \docparam{text
}{The text to insert.
}
235 \membersection{wxComboBox::Remove
}\label{wxcomboboxremove
}
237 \func{void
}{Remove
}{\param{long
}{ from
},
\param{long
}{ to
}}
239 Removes the text between the two positions in the combobox text field.
241 \wxheading{Parameters
}
243 \docparam{from
}{The first position.
}
245 \docparam{to
}{The last position.
}
247 \membersection{wxComboBox::SetClientData
}\label{wxcomboboxsetclientdata
}
249 \func{void
}{SetClientData
}{\param{int
}{ n
},
\param{char*
}{data
}}
251 Associates the given client data pointer with the given item.
253 \wxheading{Parameters
}
255 \docparam{n
}{The zero-based item.
}
257 \docparam{data
}{The client data.
}
259 \membersection{wxComboBox::SetInsertionPoint
}\label{wxcomboboxsetinsertionpoint
}
261 \func{void
}{SetInsertionPoint
}{\param{long
}{ pos
}}
263 Sets the insertion point in the combobox text field.
265 \wxheading{Parameters
}
267 \docparam{pos
}{The new insertion point.
}
269 \membersection{wxComboBox::SetInsertionPointEnd
}\label{wxcomboboxsetinsertionpointend
}
271 \func{void
}{SetInsertionPointEnd
}{\void}
273 Sets the insertion point at the end of the combobox text field.
275 \membersection{wxComboBox::SetSelection
}\label{wxcomboboxsetselection
}
277 \func{void
}{SetSelection
}{\param{int
}{ n
}}
279 Selects the given item in the combobox list.
281 \func{void
}{SetSelection
}{\param{long
}{ from
},
\param{long
}{ to
}}
283 Selects the text between the two positions, in the combobox text field.
285 \wxheading{Parameters
}
287 \docparam{n
}{The zero-based item to select.
}
289 \docparam{from
}{The first position.
}
291 \docparam{to
}{The second position.
}
293 \membersection{wxComboBox::SetValue
}\label{wxcomboboxsetvalue
}
295 \func{void
}{SetValue
}{\param{const wxString\&
}{text
}}
297 Sets the text for the combobox text field.
299 \wxheading{Parameters
}
301 \docparam{text
}{The text to set.
}