# wxRadioButton Class Reference
[Controls]

`#include </home/work/projects/wx/2.9/wx/interface/wx/radiobut.h>`

Inheritance diagram for wxRadioButton:
[legend]

## Detailed Description

A radio button item is a button which usually denotes one of several mutually exclusive options.

It has a text label next to a (usually) round button.

You can create a group of mutually-exclusive radio buttons by specifying `wxRB_GROUP` for the first in the group. The group ends when another radio button group is created, or there are no more radio buttons.

## Styles

This class supports the following styles:

- wxRB_GROUP:
  Marks the beginning of a new group of radio buttons.
- wxRB_SINGLE:
  In some circumstances, radio buttons that are not consecutive siblings trigger a hang bug in Windows (only). If this happens, add this style to mark the button as not belonging to a group, and implement the mutually-exclusive group behaviour yourself.
- wxRB_USE_CHECKBOX:
  Use a checkbox button instead of radio button (currently supported only on PalmOS).

## Events emitted by this class

The following event handler macros redirect the events to member function handlers 'func' with prototypes like:

void handlerFuncName(wxCommandEvent& event)

Event macros for events emitted by this class:

- EVT_RADIOBUTTON(id, func):
  Process a `wxEVT_COMMAND_RADIOBUTTON_SELECTED` event, when the radiobutton is clicked.

##

Library: wxCore
Category: Controls
Appearance:

wxMSW appearance | wxGTK appearance | wxMac appearance

See also:
  Events and Event Handling, wxRadioBox, wxCheckBox

## Public Member Functions

| wxRadioButton ()
| Default constructor.
| wxRadioButton (wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxRadioButtonNameStr)
| Constructor, creating and showing a radio button.
virtual | ~wxRadioButton ()
| Destructor, destroying the radio button item.
bool | Create (wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxRadioButtonNameStr)
| Creates the choice for two-step construction.
virtual bool | GetValue () const
| Returns true if the radio button is depressed, false otherwise.
virtual void | SetValue (bool value)
| Sets the radio button to selected or deselected status.

List of all members.

## Constructor & Destructor Documentation

wxRadioButton::wxRadioButton | ( |  | ) |

Default constructor.

See also:
  Create(), wxValidator

wxRadioButton::wxRadioButton | ( | wxWindow * | parent,
|  | wxWindowID | id,
|  | const wxString & | label,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `0`,
|  | const wxValidator & | validator = `wxDefaultValidator`,
|  | const wxString & | name = `wxRadioButtonNameStr` |
| ) |  |  |

Constructor, creating and showing a radio button.

Parameters:

  | parent | Parent window. Must not be NULL.
  | id | Window identifier. The value `wxID_ANY` indicates a default value.
  | label | Label for the radio button.
  | pos | Window position. If wxDefaultPosition is specified then a default position is chosen.
  | size | Window size. If wxDefaultSize is specified then a default size is chosen.
  | style | Window style. See wxRadioButton.
  | validator | Window validator.
  | name | Window name.

See also:
  Create(), wxValidator

virtual wxRadioButton::~wxRadioButton | ( |  | ) | `[virtual]`

Destructor, destroying the radio button item.

## Member Function Documentation

bool wxRadioButton::Create | ( | wxWindow * | parent,
|  | wxWindowID | id,
|  | const wxString & | label,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `0`,
|  | const wxValidator & | validator = `wxDefaultValidator`,
|  | const wxString & | name = `wxRadioButtonNameStr` |
| ) |  |  |

Creates the choice for two-step construction.

See wxRadioButton() for further details.

virtual bool wxRadioButton::GetValue | ( |  | ) | const`[virtual]`

Returns true if the radio button is depressed, false otherwise.

virtual void wxRadioButton::SetValue | ( | bool | value | ) | `[virtual]`

Sets the radio button to selected or deselected status.

This does not cause a `wxEVT_COMMAND_RADIOBUTTON_SELECTED` event to get emitted.

If the radio button belongs to a group you can only select a radio button (which will deselect the previously selected button) and you therefore must not call this method with value set to false in that case.

Parameters:

  | value | true to select, false to deselect.

|  | [ top ]