## wxSingleChoiceDialog

This class represents a dialog that shows a list of strings, and allows the user to select one. Double-clicking on a list item is equivalent to single-clicking and then pressing OK.

Derived from

wxDialog
wxWindow
wxEvtHandler
wxObject

Include files

<wx/choicdlg.h>

See also

wxSingleChoiceDialog overview, wxMultiChoiceDialog

Members

wxSingleChoiceDialog::wxSingleChoiceDialog
wxSingleChoiceDialog::GetSelection
wxSingleChoiceDialog::GetSelectionClientData
wxSingleChoiceDialog::GetStringSelection
wxSingleChoiceDialog::SetSelection
wxSingleChoiceDialog::ShowModal

### wxSingleChoiceDialog::wxSingleChoiceDialog

wxSingleChoiceDialog(wxWindow* parent, const wxString& message, const wxString& caption, int n, const wxString* choices, void** clientData = NULL, long style = wxCHOICEDLG_STYLE, const wxPoint& pos = wxDefaultPosition)

wxSingleChoiceDialog(wxWindow* parent, const wxString& message, const wxString& caption, const wxArrayString& choices, void** clientData = NULL, long style = wxCHOICEDLG_STYLE, const wxPoint& pos = wxDefaultPosition)

Constructor, taking an array of wxString choices and optional client data.

Parameters

parent

Parent window.

message

Message to show on the dialog.

caption

The dialog caption.

n

The number of choices.

choices

An array of strings, or a string list, containing the choices.

clientData

An array of client data to be associated with the items. See GetSelectionClientData.

style

A dialog style (bitlist) containing flags chosen from standard dialog styles and the following:

wxOK | Show an OK button.
wxCANCEL | Show a Cancel button.
wxCENTRE | Centre the message. Not Windows.

The default value is equivalent to wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE.

pos

Dialog position. Not Windows.

Remarks

Use wxSingleChoiceDialog::ShowModal to show the dialog.

wxPython note: For Python the two parameters `n` and `choices` are collapsed into a single parameter `choices` which is expected to be a Python list of strings.

wxPerl note: In wxPerl there is just an array reference in place of `n` and `choices`, and the client data array, if present, must have the same length as the choices array.

### wxSingleChoiceDialog::GetSelection

int GetSelection() const

Returns the index of selected item.

### wxSingleChoiceDialog::GetSelectionClientData

char* GetSelectionClientData() const

Returns the client data associated with the selection.

### wxSingleChoiceDialog::GetStringSelection

wxString GetStringSelection() const

Returns the selected string.

### wxSingleChoiceDialog::SetSelection

void SetSelection(int selection) const

Sets the index of the initially selected item.

### wxSingleChoiceDialog::ShowModal

int ShowModal()

Shows the dialog, returning either wxID_OK or wxID_CANCEL.