1 \section{\class{wxChoice
}}\label{wxchoice
}
3 A choice item is used to select one of a list of strings. Unlike a
4 listbox, only the selection is visible until the user pulls down the
7 \wxheading{Derived from
}
9 \helpref{wxControl
}{wxcontrol
}\\
10 \helpref{wxWindow
}{wxwindow
}\\
11 \helpref{wxEvtHandler
}{wxevthandler
}\\
12 \helpref{wxObject
}{wxobject
}
14 \wxheading{Include files
}
18 \wxheading{Window styles
}
20 There are no special styles for wxChoice.
22 See also
\helpref{window styles overview
}{windowstyles
}.
24 \wxheading{Event handling
}
27 \begin{twocollist
}\itemsep=
0pt
28 \twocolitem{{\bf EVT
\_CHOICE(id, func)
}}{Process a wxEVT
\_COMMAND\_CHOICE\_SELECTED event,
29 when an item on the list is selected.
}
34 \helpref{wxListBox
}{wxlistbox
},
\helpref{wxComboBox
}{wxcombobox
},
35 \rtfsp\helpref{wxCommandEvent
}{wxcommandevent
}
37 \latexignore{\rtfignore{\wxheading{Members
}}}
39 \membersection{wxChoice::wxChoice
}\label{wxchoiceconstr
}
41 \func{}{wxChoice
}{\void}
45 \func{}{wxChoice
}{\param{wxWindow *
}{parent
},
\param{wxWindowID
}{ id
},
\rtfsp
46 \param{const wxPoint\&
}{pos
},
\param{const wxSize\&
}{ size
},
\rtfsp
47 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
48 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``choice"
}}
50 Constructor, creating and showing a choice.
52 \wxheading{Parameters
}
54 \docparam{parent
}{Parent window. Must not be NULL.
}
56 \docparam{id
}{Window identifier. A value of -
1 indicates a default value.
}
58 \docparam{pos
}{Window position.
}
60 \docparam{size
}{Window size. If the default size (-
1, -
1) is specified then the choice is sized
63 \docparam{n
}{Number of strings with which to initialise the choice control.
}
65 \docparam{choices
}{An array of strings with which to initialise the choice control.
}
67 \docparam{style
}{Window style. See
\helpref{wxChoice
}{wxchoice
}.
}
69 \docparam{validator
}{Window validator.
}
71 \docparam{name
}{Window name.
}
75 \helpref{wxChoice::Create
}{wxchoicecreate
},
\helpref{wxValidator
}{wxvalidator
}
77 \pythonnote{The wxChoice constructor in wxPython reduces the
{\tt n
}
78 and
{\tt choices
} arguments are to a single argument, which is
81 \perlnote{In wxPerl there is just an array reference in place of
{\tt n
}
84 \membersection{wxChoice::
\destruct{wxChoice
}}
86 \func{}{\destruct{wxChoice
}}{\void}
88 Destructor, destroying the choice item.
90 \membersection{wxChoice::Append
}\label{wxchoiceappend
}
92 \func{void
}{Append
}{\param{const wxString\&
}{ item
}}
94 Adds the item to the end of the choice control.
96 \func{void
}{Append
}{\param{const wxString\&
}{ item
},
\param{void*
}{clientData
}}
98 Adds the item to the end of the combobox, associating the given data
101 \wxheading{Parameters
}
103 \docparam{item
}{String to add.
}
105 \docparam{clientData
}{Client data to associate with the item.
}
107 \membersection{wxChoice::Clear
}\label{wxchoiceclear
}
109 \func{void
}{Clear
}{\void}
111 Clears the strings from the choice item.
113 \membersection{wxChoice::Create
}\label{wxchoicecreate
}
115 \func{bool
}{Create
}{\param{wxWindow *
}{parent
},
\param{wxWindowID
}{ id
},
\rtfsp
116 \param{const wxPoint\&
}{pos
},
\param{const wxSize\&
}{ size
},
\rtfsp
117 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
118 \param{long
}{ style =
0},
\param{const wxString\&
}{name = ``choice"
}}
120 Creates the choice for two-step construction. See
\helpref{wxChoice::wxChoice
}{wxchoiceconstr
}.
122 \membersection{wxChoice::FindString
}\label{wxchoicefindstring
}
124 \constfunc{int
}{FindString
}{\param{const wxString\&
}{string
}}
126 Finds a choice matching the given string.
128 \wxheading{Parameters
}
130 \docparam{string
}{String to find.
}
132 \wxheading{Return value
}
134 Returns the position if found, or -
1 if not found.
136 \membersection{wxChoice::GetColumns
}\label{wxchoicegetcolumns
}
138 \constfunc{int
}{GetColumns
}{\void}
140 Gets the number of columns in this choice item.
144 This is implemented for Motif only.
146 \membersection{wxChoice::GetClientData
}\label{wxchoicegetclientdata
}
148 \constfunc{void*
}{GetClientData
}{\param{int
}{ n
}}
150 Returns a pointer to the client data associated with the given item (if any).
152 \wxheading{Parameters
}
154 \docparam{n
}{An item, starting from zero.
}
156 \wxheading{Return value
}
158 A pointer to the client data, or NULL if the item was not found.
160 \membersection{wxChoice::GetCount
}\label{wxchoicegetcount
}
162 \constfunc{int
}{GetCount
}{\void}
164 Returns the number of items in the choice.
166 \membersection{wxChoice::GetSelection
}\label{wxchoicegetselection
}
168 \constfunc{int
}{GetSelection
}{\void}
170 Gets the id (position) of the selected string, or -
1 if there is no selection.
172 \membersection{wxChoice::GetString
}\label{wxchoicegetstring
}
174 \constfunc{wxString
}{GetString
}{\param{int
}{ n
}}
176 Returns the string at the given position.
178 \wxheading{Parameters
}
180 \docparam{n
}{The zero-based position.
}
182 \wxheading{Return value
}
184 The string at the given position, or the empty string if
{\it n
} is invalid.
186 \membersection{wxChoice::GetStringSelection
}\label{wxchoicegetstringselection
}
188 \constfunc{wxString
}{GetStringSelection
}{\void}
190 Gets the selected string, or the empty string if no string is selected.
192 \membersection{wxChoice::Number
}\label{wxchoicenumber
}
194 \constfunc{int
}{Number
}{\void}
196 {\bf Obsolescence note:
} This method is obsolete and was replaced with
197 \helpref{GetCount
}{wxchoicegetcount
}, please use the new method in the new
198 code. This method is only available if wxWindows was compiled with
199 {\tt WXWIN
\_COMPATIBILITY\_2\_2} defined and will disappear completely in
202 Returns the number of strings in the choice control.
204 \membersection{wxChoice::SetClientData
}\label{wxchoicesetclientdata
}
206 \func{void
}{SetClientData
}{\param{int
}{ n
},
\param{void*
}{data
}}
208 Associates the given client data pointer with the given item.
210 \wxheading{Parameters
}
212 \docparam{n
}{The zero-based item.
}
214 \docparam{data
}{The client data.
}
216 \membersection{wxChoice::SetColumns
}\label{wxchoicesetcolumns
}
218 \func{void
}{SetColumns
}{\param{int
}{ n =
1}}
220 Sets the number of columns in this choice item.
222 \wxheading{Parameters
}
224 \docparam{n
}{Number of columns.
}
228 This is implemented for Motif only.
230 \membersection{wxChoice::SetSelection
}\label{wxchoicesetselection
}
232 \func{void
}{SetSelection
}{\param{int
}{ n
}}
234 Sets the choice by passing the desired string position. This does not cause
235 a wxEVT
\_COMMAND\_CHOICE\_SELECTED event to get emitted.
237 \wxheading{Parameters
}
239 \docparam{n
}{The string position to select, starting from zero.
}
243 \membersection{wxChoice::SetString
}\label{wxchoicesetstring
}
245 \func{void
}{SetString
}{\param{int
}{n
},
\param{const wxString\&
}{text
}}
247 Replaces the specified string in the control with another one.
249 \wxheading{Parameters
}
251 \docparam{n
}{The zero-based index of the string to replace
}
253 \docparam{text
}{The new value for this item
}
255 {\bf NB:
} This method is currently not implemented in wxGTK.
257 \helpref{wxChoice::SetStringSelection
}{wxchoicesetstringselection
}
259 \membersection{wxChoice::SetStringSelection
}\label{wxchoicesetstringselection
}
261 \func{void
}{SetStringSelection
}{\param{const wxString\&
}{ string
}}
263 Sets the choice by passing the desired string. This does not cause
264 a wxEVT
\_COMMAND\_CHOICE\_SELECTED event to get emitted.
266 \wxheading{Parameters
}
268 \docparam{string
}{The string to select.
}
272 \helpref{wxChoice::SetSelection
}{wxchoicesetselection
}