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{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. Windows only.
}
25 \twocolitem{\windowstyle{wxCB
\_DROPDOWN}}{Creates a combobox with a drop-down list.
}
26 \twocolitem{\windowstyle{wxCB
\_READONLY}}{Same as wxCB
\_DROPDOWN but only the
27 strings specified as the combobox choices can be selected, it is impossible to
28 select (even from a program) a string which is not in the choices list.
}
29 \twocolitem{\windowstyle{wxCB
\_SORT}}{Sorts the entries in the list alphabetically.
}
32 See also
\helpref{window styles overview
}{windowstyles
}.
34 \wxheading{Event handling
}
37 \begin{twocollist
}\itemsep=
0pt
38 \twocolitem{{\bf EVT
\_COMBOBOX(id, func)
}}{Process a wxEVT
\_COMMAND\_COMBOBOX\_SELECTED event,
39 when an item on the list is selected.
}
40 \twocolitem{{\bf EVT
\_TEXT(id, func)
}}{Process a wxEVT
\_COMMAND\_TEXT\_UPDATED event,
41 when the combobox text changes.
}
46 \helpref{wxListBox
}{wxlistbox
},
\helpref{wxTextCtrl
}{wxtextctrl
},
\helpref{wxChoice
}{wxchoice
},
47 \rtfsp\helpref{wxCommandEvent
}{wxcommandevent
}
49 \latexignore{\rtfignore{\wxheading{Members
}}}
51 \membersection{wxComboBox::wxComboBox
}\label{wxcomboboxconstr
}
53 \func{}{wxComboBox
}{\void}
57 \func{}{wxComboBox
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
58 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
59 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
60 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
62 Constructor, creating and showing a combobox.
64 \wxheading{Parameters
}
66 \docparam{parent
}{Parent window. Must not be NULL.
}
68 \docparam{id
}{Window identifier. A value of -
1 indicates a default value.
}
70 \docparam{value
}{Initial selection string. An empty string indicates no selection.
}
72 \docparam{pos
}{Window position.
}
74 \docparam{size
}{Window size. If the default size (-
1, -
1) is specified then the window is sized
77 \docparam{n
}{Number of strings with which to initialise the control.
}
79 \docparam{choices
}{An array of strings with which to initialise the control.
}
81 \docparam{style
}{Window style. See
\helpref{wxComboBox
}{wxcombobox
}.
}
83 \docparam{validator
}{Window validator.
}
85 \docparam{name
}{Window name.
}
89 \helpref{wxComboBox::Create
}{wxcomboboxcreate
},
\helpref{wxValidator
}{wxvalidator
}
91 \pythonnote{The wxComboBox constructor in wxPython reduces the
{\tt n
}
92 and
{\tt choices
} arguments are to a single argument, which is
95 \perlnote{In wxPerl there is just an array reference in place of
{\tt n
}
98 \membersection{wxComboBox::
\destruct{wxComboBox
}}
100 \func{}{\destruct{wxComboBox
}}{\void}
102 Destructor, destroying the combobox.
104 \membersection{wxComboBox::Create
}\label{wxcomboboxcreate
}
106 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
107 \param{const wxString\&
}{value = ``"
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
108 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
109 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``comboBox"
}}
111 Creates the combobox for two-step construction. Derived classes
112 should call or replace this function. See
\helpref{wxComboBox::wxComboBox
}{wxcomboboxconstr
}\rtfsp
115 \membersection{wxComboBox::Copy
}\label{wxcomboboxcopy
}
117 \func{void
}{Copy
}{\void}
119 Copies the selected text to the clipboard.
121 \membersection{wxComboBox::Cut
}\label{wxcomboboxcut
}
123 \func{void
}{Cut
}{\void}
125 Copies the selected text to the clipboard and removes the selection.
127 \membersection{wxComboBox::GetInsertionPoint
}\label{wxcomboboxgetinsertionpoint
}
129 \constfunc{long
}{GetInsertionPoint
}{\void}
131 Returns the insertion point for the combobox's text field.
133 \membersection{wxComboBox::GetLastPosition
}\label{wxcomboboxgetlastposition
}
135 \constfunc{long
}{GetLastPosition
}{\void}
137 Returns the last position in the combobox text field.
139 \membersection{wxComboBox::GetValue
}\label{wxcomboboxgetvalue
}
141 \constfunc{wxString
}{GetValue
}{\void}
143 Returns the current value in the combobox text field.
145 \membersection{wxComboBox::Paste
}\label{wxcomboboxpaste
}
147 \func{void
}{Paste
}{\void}
149 Pastes text from the clipboard to the text field.
151 \membersection{wxComboBox::Replace
}\label{wxcomboboxreplace
}
153 \func{void
}{Replace
}{\param{long
}{ from
},
\param{long
}{ to
},
\param{const wxString\&
}{text
}}
155 Replaces the text between two positions with the given text, in the combobox text field.
157 \wxheading{Parameters
}
159 \docparam{from
}{The first position.
}
161 \docparam{to
}{The second position.
}
163 \docparam{text
}{The text to insert.
}
165 \membersection{wxComboBox::Remove
}\label{wxcomboboxremove
}
167 \func{void
}{Remove
}{\param{long
}{ from
},
\param{long
}{ to
}}
169 Removes the text between the two positions in the combobox text field.
171 \wxheading{Parameters
}
173 \docparam{from
}{The first position.
}
175 \docparam{to
}{The last position.
}
177 \membersection{wxComboBox::SetInsertionPoint
}\label{wxcomboboxsetinsertionpoint
}
179 \func{void
}{SetInsertionPoint
}{\param{long
}{ pos
}}
181 Sets the insertion point in the combobox text field.
183 \wxheading{Parameters
}
185 \docparam{pos
}{The new insertion point.
}
187 \membersection{wxComboBox::SetInsertionPointEnd
}\label{wxcomboboxsetinsertionpointend
}
189 \func{void
}{SetInsertionPointEnd
}{\void}
191 Sets the insertion point at the end of the combobox text field.
193 \membersection{wxComboBox::SetSelection
}\label{wxcomboboxsetselection
}
195 \func{void
}{SetSelection
}{\param{long
}{ from
},
\param{long
}{ to
}}
197 Selects the text between the two positions, in the combobox text field.
199 \wxheading{Parameters
}
201 \docparam{from
}{The first position.
}
203 \docparam{to
}{The second position.
}
205 \pythonnote{This method is called
{\tt SetMark
} in wxPython,
{\tt SetSelection
}
207 \helpref{wxControlWithItems::SetSelection
}{wxcontrolwithitemssetselection
}.
}
209 \membersection{wxComboBox::SetValue
}\label{wxcomboboxsetvalue
}
211 \func{void
}{SetValue
}{\param{const wxString\&
}{text
}}
213 Sets the text for the combobox text field.
215 {\bf NB:
} For a combobox with
{\tt wxCB
\_READONLY} style the string must be in
216 the combobox choices list, otherwise the call to SetValue() is ignored.
218 \wxheading{Parameters
}
220 \docparam{text
}{The text to set.
}