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{Window styles
}
16 There are no special styles for wxChoice.
18 See also
\helpref{window styles overview
}{windowstyles
}.
20 \wxheading{Event handling
}
23 \begin{twocollist
}\itemsep=
0pt
24 \twocolitem{{\bf EVT
\_CHOICE(id, func)
}}{Process a wxEVT
\_COMMAND\_CHOICE\_SELECTED event,
25 when an item on the list is selected.
}
30 \helpref{wxListBox
}{wxlistbox
},
\helpref{wxComboBox
}{wxcombobox
},
31 \rtfsp\helpref{wxCommandEvent
}{wxcommandevent
}
33 \latexignore{\rtfignore{\wxheading{Members
}}}
35 \membersection{wxChoice::wxChoice
}\label{wxchoiceconstr
}
37 \func{}{wxChoice
}{\void}
41 \func{}{wxChoice
}{\param{wxWindow *
}{parent
},
\param{wxWindowID
}{ id
},
\rtfsp
42 \param{const wxPoint\&
}{pos
},
\param{const wxSize\&
}{ size
},
\rtfsp
43 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
44 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``choice"
}}
46 Constructor, creating and showing a choice.
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 choice is sized
59 \docparam{n
}{Number of strings with which to initialise the choice control.
}
61 \docparam{choices
}{An array of strings with which to initialise the choice control.
}
63 \docparam{style
}{Window style. See
\helpref{wxChoice
}{wxchoice
}.
}
65 \docparam{validator
}{Window validator.
}
67 \docparam{name
}{Window name.
}
71 \helpref{wxChoice::Create
}{wxchoicecreate
},
\helpref{wxValidator
}{wxvalidator
}
73 \membersection{wxChoice::
\destruct{wxChoice
}}
75 \func{}{\destruct{wxChoice
}}{\void}
77 Destructor, destroying the choice item.
79 \membersection{wxChoice::Append
}\label{wxchoiceappend
}
81 \func{void
}{Append
}{\param{const wxString\&
}{ item
}}
83 Adds the item to the end of the choice control.
85 \wxheading{Parameters
}
87 \docparam{item
}{String to add.
}
89 \membersection{wxChoice::Clear
}\label{wxchoiceclear
}
91 \func{void
}{Clear
}{\void}
93 Clears the strings from the choice item.
95 \membersection{wxChoice::Create
}\label{wxchoicecreate
}
97 \func{bool
}{Create
}{\param{wxWindow *
}{parent
},
\param{wxWindowID
}{ id
},
\rtfsp
98 \param{const wxPoint\&
}{pos
},
\param{const wxSize\&
}{ size
},
\rtfsp
99 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
100 \param{long
}{ style =
0},
\param{const wxString\&
}{name = ``choice"
}}
102 Creates the choice for two-step construction. See
\helpref{wxChoice::wxChoice
}{wxchoiceconstr
}.
104 \membersection{wxChoice::FindString
}\label{wxchoicefindstring
}
106 \constfunc{int
}{FindString
}{\param{const wxString\&
}{string
}}
108 Finds a choice matching the given string.
110 \wxheading{Parameters
}
112 \docparam{string
}{String to find.
}
114 \wxheading{Return value
}
116 Returns the position if found, or -
1 if not found.
118 \membersection{wxChoice::GetColumns
}\label{wxchoicegetcolumns
}
120 \constfunc{int
}{GetColumns
}{\void}
122 Gets the number of columns in this choice item.
126 This is implemented for Motif only.
128 \membersection{wxChoice::GetSelection
}\label{wxchoicegetselection
}
130 \constfunc{int
}{GetSelection
}{\void}
132 Gets the id (position) of the selected string, or -
1 if there is no selection.
134 \membersection{wxChoice::GetString
}\label{wxchoicegetstring
}
136 \constfunc{wxString
}{GetString
}{\param{int
}{ n
}}
138 Returns the string at the given position.
140 \wxheading{Parameters
}
142 \docparam{n
}{The zero-based position.
}
144 \wxheading{Return value
}
146 The string at the given position, or the empty string if
{\it n
} is invalid.
148 \membersection{wxChoice::GetStringSelection
}\label{wxchoicegetstringselection
}
150 \constfunc{wxString
}{GetStringSelection
}{\void}
152 Gets the selected string, or the empty string if no string is selected.
154 \membersection{wxChoice::Number
}\label{wxchoicenumber
}
156 \constfunc{int
}{Number
}{\void}
158 Returns the number of strings in the choice control.
160 \membersection{wxChoice::SetColumns
}\label{wxchoicesetcolumns
}
162 \func{void
}{SetColumns
}{\param{int
}{ n =
1}}
164 Sets the number of columns in this choice item.
166 \wxheading{Parameters
}
168 \docparam{n
}{Number of columns.
}
172 This is implemented for Motif only.
174 \membersection{wxChoice::SetSelection
}\label{wxchoicesetselection
}
176 \func{void
}{SetSelection
}{\param{int
}{ n
}}
178 Sets the choice by passing the desired string position.
180 \wxheading{Parameters
}
182 \docparam{n
}{The string position to select, starting from zero.
}
186 \helpref{wxChoice::SetStringSelection
}{wxchoicesetstringselection
}
188 \membersection{wxChoice::SetStringSelection
}\label{wxchoicesetstringselection
}
190 \func{void
}{SetStringSelection
}{\param{const wxString\&
}{ string
}}
192 Sets the choice by passing the desired string.
194 \wxheading{Parameters
}
196 \docparam{string
}{The string to select.
}
200 \helpref{wxChoice::SetSelection
}{wxchoicesetselection
}