## wxCheckBox

A checkbox is a labelled box which is either on (checkmark is visible) or off (no checkmark).

Derived from

wxControl
wxWindow
wxEvtHandler
wxObject

Include files

<wx/checkbox.h>

Window styles

There are no special styles for wxCheckBox.

See also window styles overview.

Event handling

EVT_CHECKBOX(id, func) | Process a wxEVT_COMMAND_CHECKBOX_CLICKED event, when the checkbox is clicked.

See also

wxRadioButton, wxCommandEvent

Members

wxCheckBox::wxCheckBox
wxCheckBox::~wxCheckBox
wxCheckBox::Create
wxCheckBox::GetValue
wxCheckBox::SetValue

### wxCheckBox::wxCheckBox

wxCheckBox()

Default constructor.

wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& val, const wxString& name = "checkBox")

Constructor, creating and showing a checkbox.

Parameters

parent

Parent window. Must not be NULL.

id

Checkbox identifier. A value of -1 indicates a default value.

label

Text to be displayed next to the checkbox.

pos

Checkbox position. If the position (-1, -1) is specified then a default position is chosen.

size

Checkbox size. If the default size (-1, -1) is specified then a default size is chosen.

style

Window style. See wxCheckBox.

validator

Window validator.

name

Window name.

See also

wxCheckBox::Create, wxValidator

### wxCheckBox::~wxCheckBox

~wxCheckBox()

Destructor, destroying the checkbox.

### wxCheckBox::Create

bool Create(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& val, const wxString& name = "checkBox")

Creates the checkbox for two-step construction. See wxCheckBox::wxCheckBox for details.

### wxCheckBox::GetValue

bool GetValue() const

Gets the state of the checkbox.

Return value

Returns TRUE if it is checked, FALSE otherwise.

### wxCheckBox::SetValue

void SetValue(const bool state)

Sets the checkbox to the given state. This does not cause a wxEVT_COMMAND_CHECKBOX_CLICKED event to get emitted.

Parameters

state

If TRUE, the check is on, otherwise it is off.