1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
|
<HTML>
<head><title>wxComboBox</title></head>
<BODY BGCOLOR=#FFFFFF>
<A NAME="wxcombobox"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx22.htm#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx49.htm#wxcolourdialog"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx51.htm#wxcommand"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>
<H2>wxComboBox</H2>
<P>
A combobox is like a combination of an edit control and a listbox. It can be
displayed as static list with editable or read-only text field; or a drop-down list with
text field; or a drop-down list without a text field.<P>
A combobox permits a single selection only. Combobox items are numbered from zero.<P>
<B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
<A HREF="wx41.htm#wxchoice">wxChoice</A><BR>
<A HREF="wx56.htm#wxcontrol">wxControl</A><BR>
<A HREF="wx260.htm#wxwindow">wxWindow</A><BR>
<A HREF="wx85.htm#wxevthandler">wxEvtHandler</A><BR>
<A HREF="wx158.htm#wxobject">wxObject</A><P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
<wx/combo.h><P>
<B><FONT COLOR="#FF0000">Window styles</FONT></B><P>
<TABLE>
<TR><TD VALIGN=TOP>
<B>wxCB_SIMPLE</B>
</TD>
<TD VALIGN=TOP>
Creates a combobox with a permanently displayed list.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxCB_DROPDOWN</B>
</TD>
<TD VALIGN=TOP>
Creates a combobox with a drop-down list.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxCB_READONLY</B>
</TD>
<TD VALIGN=TOP>
Creates a combo box consisting of a drop-down list and static text item
displaying the current selection.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxCB_SORT</B>
</TD>
<TD VALIGN=TOP>
Sorts the entries in the list alphabetically.
</TD></TR>
</TABLE>
<P>
See also <A HREF="wx305.htm#windowstyles">window styles overview</A>.<P>
<B><FONT COLOR="#FF0000">Event handling</FONT></B><P>
<TABLE>
<TR><TD VALIGN=TOP>
<B>EVT_COMBOBOX(id, func)</B>
</TD>
<TD VALIGN=TOP>
Process a wxEVT_COMMAND_COMBOBOX_SELECTED event,
when an item on the list is selected.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>EVT_TEXT(id, func)</B>
</TD>
<TD VALIGN=TOP>
Process a wxEVT_COMMAND_TEXT_UPDATED event,
when the combobox text changes.
</TD></TR>
</TABLE>
<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx128.htm#wxlistbox">wxListBox</A>, <A HREF="wx240.htm#wxtextctrl">wxTextCtrl</A>, <A HREF="wx41.htm#wxchoice">wxChoice</A>,
<A HREF="wx52.htm#wxcommandevent">wxCommandEvent</A><P>
<B><FONT COLOR="#FF0000">Members</FONT></B><P>
<A HREF="#wxcomboboxconstr">wxComboBox::wxComboBox</A><BR>
<A HREF="#topic94">wxComboBox::~wxComboBox</A><BR>
<A HREF="#wxcomboboxappend">wxComboBox::Append</A><BR>
<A HREF="#wxcomboboxclear">wxComboBox::Clear</A><BR>
<A HREF="#wxcomboboxcreate">wxComboBox::Create</A><BR>
<A HREF="#wxcomboboxcopy">wxComboBox::Copy</A><BR>
<A HREF="#wxcomboboxcut">wxComboBox::Cut</A><BR>
<A HREF="#wxcomboboxdelete">wxComboBox::Delete</A><BR>
<A HREF="#wxcomboboxfindstring">wxComboBox::FindString</A><BR>
<A HREF="#wxcomboboxgetclientdata">wxComboBox::GetClientData</A><BR>
<A HREF="#wxcomboboxgetinsertionpoint">wxComboBox::GetInsertionPoint</A><BR>
<A HREF="#wxcomboboxgetlastposition">wxComboBox::GetLastPosition</A><BR>
<A HREF="#wxcomboboxgetselection">wxComboBox::GetSelection</A><BR>
<A HREF="#wxcomboboxgetstring">wxComboBox::GetString</A><BR>
<A HREF="#wxcomboboxgetstringselection">wxComboBox::GetStringSelection</A><BR>
<A HREF="#wxcomboboxgetvalue">wxComboBox::GetValue</A><BR>
<A HREF="#wxcomboboxnumber">wxComboBox::Number</A><BR>
<A HREF="#wxcomboboxpaste">wxComboBox::Paste</A><BR>
<A HREF="#wxcomboboxreplace">wxComboBox::Replace</A><BR>
<A HREF="#wxcomboboxremove">wxComboBox::Remove</A><BR>
<A HREF="#wxcomboboxsetclientdata">wxComboBox::SetClientData</A><BR>
<A HREF="#wxcomboboxsetinsertionpoint">wxComboBox::SetInsertionPoint</A><BR>
<A HREF="#wxcomboboxsetinsertionpointend">wxComboBox::SetInsertionPointEnd</A><BR>
<A HREF="#wxcomboboxsetselection">wxComboBox::SetSelection</A><BR>
<A HREF="#wxcomboboxsetvalue">wxComboBox::SetValue</A><BR>
<P>
<HR>
<A NAME="wxcomboboxconstr"></A>
<H3>wxComboBox::wxComboBox</H3>
<P>
<B></B> <B>wxComboBox</B>()<P>
Default constructor.<P>
<B></B> <B>wxComboBox</B>(<B>wxWindow*</B><I> parent</I>, <B>wxWindowID</B><I> id</I>,
<B>const wxString& </B><I>value = ""</I>, <B>const wxPoint&</B><I> pos = wxDefaultPosition</I>, <B>const wxSize&</B><I> size = wxDefaultSize</I>,
<B>int</B><I> n</I>, <B>const wxString </B><I>choices[]</I>,
<B>long</B><I> style = 0</I>, <B>const wxValidator& </B><I>validator = wxDefaultValidator</I>, <B>const wxString& </B><I>name = "comboBox"</I>)<P>
Constructor, creating and showing a combobox.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>parent</I><UL><UL>
Parent window. Must not be NULL.</UL></UL>
<P>
<I>id</I><UL><UL>
Window identifier. A value of -1 indicates a default value.</UL></UL>
<P>
<I>pos</I><UL><UL>
Window position.</UL></UL>
<P>
<I>size</I><UL><UL>
Window size. If the default size (-1, -1) is specified then the window is sized
appropriately.</UL></UL>
<P>
<I>n</I><UL><UL>
Number of strings with which to initialise the control.</UL></UL>
<P>
<I>choices</I><UL><UL>
An array of strings with which to initialise the control.</UL></UL>
<P>
<I>style</I><UL><UL>
Window style. See <A HREF="wx50.htm#wxcombobox">wxComboBox</A>.</UL></UL>
<P>
<I>validator</I><UL><UL>
Window validator.</UL></UL>
<P>
<I>name</I><UL><UL>
Window name.</UL></UL>
<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx50.htm#wxcomboboxcreate">wxComboBox::Create</A>, <A HREF="wx255.htm#wxvalidator">wxValidator</A><P>
<B><FONT COLOR="#0000C8">wxPython note:</FONT></B><BR>
The wxComboBox constructor in wxPython reduces the <TT>n</TT>
and <TT>choices</TT> arguments are to a single argument, which is
a list of strings.<P>
<HR>
<A NAME="topic94"></A>
<H3>wxComboBox::~wxComboBox</H3>
<P>
<B></B> <B>~wxComboBox</B>()<P>
Destructor, destroying the combobox.<P>
<HR>
<A NAME="wxcomboboxappend"></A>
<H3>wxComboBox::Append</H3>
<P>
<B>void</B> <B>Append</B>(<B>const wxString& </B><I>item</I>)<P>
Adds the item to the end of the combobox.<P>
<B>void</B> <B>Append</B>(<B>const wxString& </B><I> item</I>, <B>char* </B><I>clientData</I>)<P>
Adds the item to the end of the combobox, associating the given data
with the item.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>item</I><UL><UL>
The string to add.</UL></UL>
<P>
<I>clientData</I><UL><UL>
Client data to associate with the item.</UL></UL>
<P>
<HR>
<A NAME="wxcomboboxclear"></A>
<H3>wxComboBox::Clear</H3>
<P>
<B>void</B> <B>Clear</B>()<P>
Clears all strings from the combobox.<P>
<HR>
<A NAME="wxcomboboxcreate"></A>
<H3>wxComboBox::Create</H3>
<P>
<B>bool</B> <B>Create</B>(<B>wxWindow*</B><I> parent</I>, <B>wxWindowID</B><I> id</I>,
<B>const wxString& </B><I>value = ""</I>, <B>const wxPoint&</B><I> pos = wxDefaultPosition</I>, <B>const wxSize&</B><I> size = wxDefaultSize</I>,
<B>int</B><I> n</I>, <B>const wxString </B><I>choices[]</I>,
<B>long</B><I> style = 0</I>, <B>const wxValidator& </B><I>validator = wxDefaultValidator</I>, <B>const wxString& </B><I>name = "comboBox"</I>)<P>
Creates the combobox for two-step construction. Derived classes
should call or replace this function. See <A HREF="wx50.htm#wxcomboboxconstr">wxComboBox::wxComboBox</A>
for further details.<P>
<HR>
<A NAME="wxcomboboxcopy"></A>
<H3>wxComboBox::Copy</H3>
<P>
<B>void</B> <B>Copy</B>()<P>
Copies the selected text to the clipboard.<P>
<HR>
<A NAME="wxcomboboxcut"></A>
<H3>wxComboBox::Cut</H3>
<P>
<B>void</B> <B>Cut</B>()<P>
Copies the selected text to the clipboard and removes the selection.<P>
<HR>
<A NAME="wxcomboboxdelete"></A>
<H3>wxComboBox::Delete</H3>
<P>
<B>void</B> <B>Delete</B>(<B>int</B><I> n</I>)<P>
Deletes an item from the combobox.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>n</I><UL><UL>
The item to delete, starting from zero.</UL></UL>
<P>
<HR>
<A NAME="wxcomboboxfindstring"></A>
<H3>wxComboBox::FindString</H3>
<P>
<B>int</B> <B>FindString</B>(<B>const wxString& </B><I>string</I>)<P>
Finds a choice matching the given string.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>string</I><UL><UL>
The item to find.</UL></UL>
<P>
<B><FONT COLOR="#FF0000">Return value</FONT></B><P>
The position if found, or -1 if not found.<P>
<HR>
<A NAME="wxcomboboxgetclientdata"></A>
<H3>wxComboBox::GetClientData</H3>
<P>
<B>char*</B> <B>GetClientData</B>(<B>int</B><I> n</I>) <B>const</B><P>
Returns a pointer to the client data associated with the given item (if any).<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>n</I><UL><UL>
An item, starting from zero.</UL></UL>
<P>
<B><FONT COLOR="#FF0000">Return value</FONT></B><P>
A pointer to the client data, or NULL if the item was not found.<P>
<HR>
<A NAME="wxcomboboxgetinsertionpoint"></A>
<H3>wxComboBox::GetInsertionPoint</H3>
<P>
<B>long</B> <B>GetInsertionPoint</B>() <B>const</B><P>
Returns the insertion point for the combobox's text field.<P>
<HR>
<A NAME="wxcomboboxgetlastposition"></A>
<H3>wxComboBox::GetLastPosition</H3>
<P>
<B>long</B> <B>GetLastPosition</B>() <B>const</B><P>
Returns the last position in the combobox text field.<P>
<HR>
<A NAME="wxcomboboxgetselection"></A>
<H3>wxComboBox::GetSelection</H3>
<P>
<B>int</B> <B>GetSelection</B>() <B>const</B><P>
Gets the position of the selected string, or -1 if there is no selection.<P>
<HR>
<A NAME="wxcomboboxgetstring"></A>
<H3>wxComboBox::GetString</H3>
<P>
<B>wxString</B> <B>GetString</B>(<B>int</B><I> n</I>) <B>const</B><P>
Returns the string at position <I>n</I>.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>n</I><UL><UL>
The item position, starting from zero.</UL></UL>
<P>
<B><FONT COLOR="#FF0000">Return value</FONT></B><P>
The string if the item is found, otherwise the empty string.<P>
<HR>
<A NAME="wxcomboboxgetstringselection"></A>
<H3>wxComboBox::GetStringSelection</H3>
<P>
<B>wxString</B> <B>GetStringSelection</B>() <B>const</B><P>
Gets the selected string.<P>
<HR>
<A NAME="wxcomboboxgetvalue"></A>
<H3>wxComboBox::GetValue</H3>
<P>
<B>wxString</B> <B>GetValue</B>() <B>const</B><P>
Returns the current value in the combobox text field.<P>
<HR>
<A NAME="wxcomboboxnumber"></A>
<H3>wxComboBox::Number</H3>
<P>
<B>int</B> <B>Number</B>() <B>const</B><P>
Returns the number of items in the combobox list.
<HR>
<A NAME="wxcomboboxpaste"></A>
<H3>wxComboBox::Paste</H3>
<P>
<B>void</B> <B>Paste</B>()<P>
Pastes text from the clipboard to the text field.<P>
<HR>
<A NAME="wxcomboboxreplace"></A>
<H3>wxComboBox::Replace</H3>
<P>
<B>void</B> <B>Replace</B>(<B>long</B><I> from</I>, <B>long</B><I> to</I>, <B>const wxString& </B><I>text</I>)<P>
Replaces the text between two positions with the given text, in the combobox text field.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>from</I><UL><UL>
The first position.</UL></UL>
<P>
<I>to</I><UL><UL>
The second position.</UL></UL>
<P>
<I>text</I><UL><UL>
The text to insert.</UL></UL>
<P>
<HR>
<A NAME="wxcomboboxremove"></A>
<H3>wxComboBox::Remove</H3>
<P>
<B>void</B> <B>Remove</B>(<B>long</B><I> from</I>, <B>long</B><I> to</I>)<P>
Removes the text between the two positions in the combobox text field.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>from</I><UL><UL>
The first position.</UL></UL>
<P>
<I>to</I><UL><UL>
The last position.</UL></UL>
<P>
<HR>
<A NAME="wxcomboboxsetclientdata"></A>
<H3>wxComboBox::SetClientData</H3>
<P>
<B>void</B> <B>SetClientData</B>(<B>int</B><I> n</I>, <B>char* </B><I>data</I>)<P>
Associates the given client data pointer with the given item.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>n</I><UL><UL>
The zero-based item.</UL></UL>
<P>
<I>data</I><UL><UL>
The client data.</UL></UL>
<P>
<HR>
<A NAME="wxcomboboxsetinsertionpoint"></A>
<H3>wxComboBox::SetInsertionPoint</H3>
<P>
<B>void</B> <B>SetInsertionPoint</B>(<B>long</B><I> pos</I>)<P>
Sets the insertion point in the combobox text field.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>pos</I><UL><UL>
The new insertion point.</UL></UL>
<P>
<HR>
<A NAME="wxcomboboxsetinsertionpointend"></A>
<H3>wxComboBox::SetInsertionPointEnd</H3>
<P>
<B>void</B> <B>SetInsertionPointEnd</B>()<P>
Sets the insertion point at the end of the combobox text field.<P>
<HR>
<A NAME="wxcomboboxsetselection"></A>
<H3>wxComboBox::SetSelection</H3>
<P>
<B>void</B> <B>SetSelection</B>(<B>int</B><I> n</I>)<P>
Selects the given item in the combobox list.<P>
<B>void</B> <B>SetSelection</B>(<B>long</B><I> from</I>, <B>long</B><I> to</I>)<P>
Selects the text between the two positions, in the combobox text field.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>n</I><UL><UL>
The zero-based item to select.</UL></UL>
<P>
<I>from</I><UL><UL>
The first position.</UL></UL>
<P>
<I>to</I><UL><UL>
The second position.</UL></UL>
<P>
<HR>
<A NAME="wxcomboboxsetvalue"></A>
<H3>wxComboBox::SetValue</H3>
<P>
<B>void</B> <B>SetValue</B>(<B>const wxString& </B><I>text</I>)<P>
Sets the text for the combobox text field.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>text</I><UL><UL>
The text to set.</UL></UL>
<P>
</BODY></HTML>
|