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{wxControlWithItems
}{wxcontrolwithitems
}\\
12 \helpref{wxChoice
}{wxchoice
}\\
13 \helpref{wxControl
}{wxcontrol
}\\
14 \helpref{wxWindow
}{wxwindow
}\\
15 \helpref{wxEvtHandler
}{wxevthandler
}\\
16 \helpref{wxObject
}{wxobject
}
18 \wxheading{Include files
}
22 \wxheading{Window styles
}
24 \begin{twocollist
}\itemsep=
0pt
25 \twocolitem{\windowstyle{wxCB
\_SIMPLE}}{Creates a combobox with a permanently displayed list. Windows only.
}
26 \twocolitem{\windowstyle{wxCB
\_DROPDOWN}}{Creates a combobox with a drop-down list.
}
27 \twocolitem{\windowstyle{wxCB
\_READONLY}}{Same as wxCB
\_DROPDOWN but only the
28 strings specified as the combobox choices can be selected, it is impossible to
29 select (even from a program) a string which is not in the choices list.
}
30 \twocolitem{\windowstyle{wxCB
\_SORT}}{Sorts the entries in the list alphabetically.
}
33 See also
\helpref{window styles overview
}{windowstyles
}.
35 \wxheading{Event handling
}
38 \begin{twocollist
}\itemsep=
0pt
39 \twocolitem{{\bf EVT
\_COMBOBOX(id, func)
}}{Process a wxEVT
\_COMMAND\_COMBOBOX\_SELECTED event,
40 when an item on the list is selected.
}
41 \twocolitem{{\bf EVT
\_TEXT(id, func)
}}{Process a wxEVT
\_COMMAND\_TEXT\_UPDATED event,
42 when the combobox text changes.
}
47 \helpref{wxListBox
}{wxlistbox
},
\helpref{wxTextCtrl
}{wxtextctrl
},
\helpref{wxChoice
}{wxchoice
},
48 \rtfsp\helpref{wxCommandEvent
}{wxcommandevent
}
50 \latexignore{\rtfignore{\wxheading{Members
}}}
52 \membersection{wxComboBox::wxComboBox
}\label{wxcomboboxconstr
}
54 \func{}{wxComboBox
}{\void}
58 \func{}{wxComboBox
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
59 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
60 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
61 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
63 Constructor, creating and showing a combobox.
65 \wxheading{Parameters
}
67 \docparam{parent
}{Parent window. Must not be NULL.
}
69 \docparam{id
}{Window identifier. A value of -
1 indicates a default value.
}
71 \docparam{value
}{Initial selection string. An empty string indicates no selection.
}
73 \docparam{pos
}{Window position.
}
75 \docparam{size
}{Window size. If the default size (-
1, -
1) is specified then the window is sized
78 \docparam{n
}{Number of strings with which to initialise the control.
}
80 \docparam{choices
}{An array of strings with which to initialise the control.
}
82 \docparam{style
}{Window style. See
\helpref{wxComboBox
}{wxcombobox
}.
}
84 \docparam{validator
}{Window validator.
}
86 \docparam{name
}{Window name.
}
90 \helpref{wxComboBox::Create
}{wxcomboboxcreate
},
\helpref{wxValidator
}{wxvalidator
}
92 \pythonnote{The wxComboBox constructor in wxPython reduces the
{\tt n
}
93 and
{\tt choices
} arguments are to a single argument, which is
96 \perlnote{In wxPerl there is just an array reference in place of
{\tt n
}
99 \membersection{wxComboBox::
\destruct{wxComboBox
}}
101 \func{}{\destruct{wxComboBox
}}{\void}
103 Destructor, destroying the combobox.
105 \membersection{wxComboBox::Create
}\label{wxcomboboxcreate
}
107 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
108 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
109 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
110 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
112 Creates the combobox for two-step construction. Derived classes
113 should call or replace this function. See
\helpref{wxComboBox::wxComboBox
}{wxcomboboxconstr
}\rtfsp
116 \membersection{wxComboBox::Copy
}\label{wxcomboboxcopy
}
118 \func{void
}{Copy
}{\void}
120 Copies the selected text to the clipboard.
122 \membersection{wxComboBox::Cut
}\label{wxcomboboxcut
}
124 \func{void
}{Cut
}{\void}
126 Copies the selected text to the clipboard and removes the selection.
128 \membersection{wxComboBox::GetInsertionPoint
}\label{wxcomboboxgetinsertionpoint
}
130 \constfunc{long
}{GetInsertionPoint
}{\void}
132 Returns the insertion point for the combobox's text field.
134 \membersection{wxComboBox::GetLastPosition
}\label{wxcomboboxgetlastposition
}
136 \constfunc{long
}{GetLastPosition
}{\void}
138 Returns the last position in the combobox text field.
140 \membersection{wxComboBox::GetValue
}\label{wxcomboboxgetvalue
}
142 \constfunc{wxString
}{GetValue
}{\void}
144 Returns the current value in the combobox text field.
146 \membersection{wxComboBox::Paste
}\label{wxcomboboxpaste
}
148 \func{void
}{Paste
}{\void}
150 Pastes text from the clipboard to the text field.
152 \membersection{wxComboBox::Replace
}\label{wxcomboboxreplace
}
154 \func{void
}{Replace
}{\param{long
}{ from
},
\param{long
}{ to
},
\param{const wxString\&
}{text
}}
156 Replaces the text between two positions with the given text, in the combobox text field.
158 \wxheading{Parameters
}
160 \docparam{from
}{The first position.
}
162 \docparam{to
}{The second position.
}
164 \docparam{text
}{The text to insert.
}
166 \membersection{wxComboBox::Remove
}\label{wxcomboboxremove
}
168 \func{void
}{Remove
}{\param{long
}{ from
},
\param{long
}{ to
}}
170 Removes the text between the two positions in the combobox text field.
172 \wxheading{Parameters
}
174 \docparam{from
}{The first position.
}
176 \docparam{to
}{The last position.
}
178 \membersection{wxComboBox::SetInsertionPoint
}\label{wxcomboboxsetinsertionpoint
}
180 \func{void
}{SetInsertionPoint
}{\param{long
}{ pos
}}
182 Sets the insertion point in the combobox text field.
184 \wxheading{Parameters
}
186 \docparam{pos
}{The new insertion point.
}
188 \membersection{wxComboBox::SetInsertionPointEnd
}\label{wxcomboboxsetinsertionpointend
}
190 \func{void
}{SetInsertionPointEnd
}{\void}
192 Sets the insertion point at the end of the combobox text field.
194 \membersection{wxComboBox::SetSelection
}\label{wxcomboboxsetselection
}
196 \func{void
}{SetSelection
}{\param{long
}{ from
},
\param{long
}{ to
}}
198 Selects the text between the two positions, in the combobox text field.
200 \wxheading{Parameters
}
202 \docparam{from
}{The first position.
}
204 \docparam{to
}{The second position.
}
206 \pythonnote{This method is called
{\tt SetMark
} in wxPython,
{\tt SetSelection
}
208 \helpref{wxControlWithItems::SetSelection
}{wxcontrolwithitemssetselection
}.
}
210 \membersection{wxComboBox::SetValue
}\label{wxcomboboxsetvalue
}
212 \func{void
}{SetValue
}{\param{const wxString\&
}{text
}}
214 Sets the text for the combobox text field.
216 {\bf NB:
} For a combobox with
{\tt wxCB
\_READONLY} style the string must be in
217 the combobox choices list, otherwise the call to SetValue() is ignored.
219 \wxheading{Parameters
}
221 \docparam{text
}{The text to set.
}