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 \membersection{wxChoice::
\destruct{wxChoice
}}
79 \func{}{\destruct{wxChoice
}}{\void}
81 Destructor, destroying the choice item.
83 \membersection{wxChoice::Append
}\label{wxchoiceappend
}
85 \func{void
}{Append
}{\param{const wxString\&
}{ item
}}
87 Adds the item to the end of the choice control.
89 \wxheading{Parameters
}
91 \docparam{item
}{String to add.
}
93 \membersection{wxChoice::Clear
}\label{wxchoiceclear
}
95 \func{void
}{Clear
}{\void}
97 Clears the strings from the choice item.
99 \membersection{wxChoice::Create
}\label{wxchoicecreate
}
101 \func{bool
}{Create
}{\param{wxWindow *
}{parent
},
\param{wxWindowID
}{ id
},
\rtfsp
102 \param{const wxPoint\&
}{pos
},
\param{const wxSize\&
}{ size
},
\rtfsp
103 \param{int
}{ n
},
\param{const wxString
}{choices
[]},
\rtfsp
104 \param{long
}{ style =
0},
\param{const wxString\&
}{name = ``choice"
}}
106 Creates the choice for two-step construction. See
\helpref{wxChoice::wxChoice
}{wxchoiceconstr
}.
108 \membersection{wxChoice::FindString
}\label{wxchoicefindstring
}
110 \constfunc{int
}{FindString
}{\param{const wxString\&
}{string
}}
112 Finds a choice matching the given string.
114 \wxheading{Parameters
}
116 \docparam{string
}{String to find.
}
118 \wxheading{Return value
}
120 Returns the position if found, or -
1 if not found.
122 \membersection{wxChoice::GetColumns
}\label{wxchoicegetcolumns
}
124 \constfunc{int
}{GetColumns
}{\void}
126 Gets the number of columns in this choice item.
130 This is implemented for Motif only.
132 \membersection{wxChoice::GetSelection
}\label{wxchoicegetselection
}
134 \constfunc{int
}{GetSelection
}{\void}
136 Gets the id (position) of the selected string, or -
1 if there is no selection.
138 \membersection{wxChoice::GetString
}\label{wxchoicegetstring
}
140 \constfunc{wxString
}{GetString
}{\param{int
}{ n
}}
142 Returns the string at the given position.
144 \wxheading{Parameters
}
146 \docparam{n
}{The zero-based position.
}
148 \wxheading{Return value
}
150 The string at the given position, or the empty string if
{\it n
} is invalid.
152 \membersection{wxChoice::GetStringSelection
}\label{wxchoicegetstringselection
}
154 \constfunc{wxString
}{GetStringSelection
}{\void}
156 Gets the selected string, or the empty string if no string is selected.
158 \membersection{wxChoice::Number
}\label{wxchoicenumber
}
160 \constfunc{int
}{Number
}{\void}
162 Returns the number of strings in the choice control.
164 \membersection{wxChoice::SetColumns
}\label{wxchoicesetcolumns
}
166 \func{void
}{SetColumns
}{\param{int
}{ n =
1}}
168 Sets the number of columns in this choice item.
170 \wxheading{Parameters
}
172 \docparam{n
}{Number of columns.
}
176 This is implemented for Motif only.
178 \membersection{wxChoice::SetSelection
}\label{wxchoicesetselection
}
180 \func{void
}{SetSelection
}{\param{int
}{ n
}}
182 Sets the choice by passing the desired string position.
184 \wxheading{Parameters
}
186 \docparam{n
}{The string position to select, starting from zero.
}
190 \helpref{wxChoice::SetStringSelection
}{wxchoicesetstringselection
}
192 \membersection{wxChoice::SetStringSelection
}\label{wxchoicesetstringselection
}
194 \func{void
}{SetStringSelection
}{\param{const wxString\&
}{ string
}}
196 Sets the choice by passing the desired string.
198 \wxheading{Parameters
}
200 \docparam{string
}{The string to select.
}
204 \helpref{wxChoice::SetSelection
}{wxchoicesetselection
}