wxRuby Documentation Home

# Wx::RadioBox

A radio box item is used to select one of number of mutually exclusive
choices. It is displayed as a vertical column or horizontal row of
labelled buttons.

## Derived from

Control

Window

EvtHandler

Object

## Window styles

`RA_SPECIFY_ROWS` | The major dimension parameter refers to themaximum number of rows.
`RA_SPECIFY_COLS` | The major dimension parameter refers to themaximum number of columns.
`RA_USE_CHECKBOX` | Use of the checkbox controls instead of radiobuttons (currently supported only on PalmOS)

See also window styles overview.

## Event handling

evt_radiobox(id) { | event | … } | Process a EVT_COMMAND_RADIOBOX_SELECTED event,when a radiobutton is clicked.

## See also

Event handling overview, RadioButton, CheckBox

## Methods

- RadioBox.new
- RadioBox#create
- RadioBox#enable
- RadioBox#find_string
- RadioBox#get_count
- RadioBox#get_label
- RadioBox#get_selection
- RadioBox#get_string_selection
- RadioBox#get_string
- RadioBox#number
- RadioBox#set_label
- RadioBox#set_selection
- RadioBox#set_string_selection
- RadioBox#show

### RadioBox.new

RadioBox.new(%(arg-type)Window% parent, Integer id, String label, Point point = DEFAULT_POSITION, Size size = DEFAULT_SIZE, Array choices =[], Integer major_dimension = 0, Integer style = RA_SPECIFY_COLS, Validator validator = DEFAULT_VALIDATOR, String name = “radioBox”)

Constructor, creating and showing a radiobox.

#### Parameters

- parent Parent window. Must not be `nil`.
- id Window identifier. A value of -1 indicates a default value.
- label Label for the static box surrounding the radio buttons.
- pos Window position. If the position (-1, -1) is specified then a default position is chosen.
- size Window size. If the default size (-1, -1) is specified then a default size is chosen.
- choices An array of String choices with which to initialize the radiobox.
- major_dimension Specifies the maximum number of rows (if style contains RA_SPECIFY_ROWS) or columns (if style contains RA_SPECIFY_COLS) for a two-dimensional
  radiobox.
- style Window style. See RadioBox.
- validator Window validator.
- name Window name.

#### See also

RadioBox#create, Validator

### RadioBox#create

Boolean create(%(arg-type)Window% parent, Integer id, String label, Point point = DEFAULT_POSITION, Size size = DEFAULT_SIZE, Array choices = [], Integer major_dimension = 0, Integer style = RA_SPECIFY_COLS, Validator validator = DEFAULT_VALIDATOR, String name = “radioBox”)

Creates the radiobox for two-step construction. See RadioBox.new for further details.

### RadioBox#enable

Boolean enable(%(arg-type)Boolean% enable = `true`)

Enables or disables the entire radiobox.

Boolean enable(%(arg-type)Integer% n, Boolean enable = `true`)

Enables or disables an individual button in the radiobox.

#### Parameters

- enable true to enable, false to disable.
- n The zero-based button to enable or disable.

#### See also

Window#enable

### RadioBox#find_string

Integer find_string(%(arg-type)String% string)

Finds a button matching the given string, returning the position if found, or
-1 if not found.

#### Parameters

- string The string to find.

### RadioBox#get_count

Integer get_count()

Returns the number of items in the radiobox.

### RadioBox#get_label

String get_label()

Returns the radiobox label.

#### Parameters

- n The zero-based button index.

#### See also

RadioBox#set_label

### RadioBox#get_selection

Integer get_selection()

Returns the zero-based position of the selected button.

### RadioBox#get_string_selection

String get_string_selection()

Returns the selected string.

### RadioBox#get_string

String get_string(%(arg-type)Integer% n)

Returns the label for the button at the given position.

#### Parameters

- n The zero-based button position.

### RadioBox#number

Integer number()

Obsolescence note: This method is obsolete and was replaced with
get_count, please use the new method in the new
code. This method is only available if Widgets was compiled with
`WXWIN_COMPATIBILITY_2_2` defined and will disappear completely in
future versions.

Returns the number of buttons in the radiobox.

### RadioBox#set_label

set_label(%(arg-type)String% label)

Sets the radiobox label.

#### Parameters

- label The label to set.
- n The zero-based button index.

### RadioBox#set_selection

set_selection(%(arg-type)Integer% n)

Sets a button by passing the desired string position. This does not cause
a EVT_COMMAND_RADIOBOX_SELECTED event to get emitted.

#### Parameters

- n The zero-based button position.

### RadioBox#set_string_selection

set_string_selection(%(arg-type)String% string)

Sets the selection to a button by passing the desired string. This does not cause
a EVT_COMMAND_RADIOBOX_SELECTED event to get emitted.

#### Parameters

- string The label of the button to select.

### RadioBox#show

Boolean show(%(arg-type)Boolean% show = `true`)

Shows or hides the entire radiobox.

Boolean show(%(arg-type)Integer% item, Boolean show = `true`)

Shows or hides individual buttons.

#### Parameters

- show true to show, false to hide.
- item The zero-based position of the button to show or hide.

#### Return value

`true` if the box or item has been shown or hidden or `false` if nothing was
done because it already was in the requested state.

#### See also

Window#show

[This page automatically generated from the Textile source at 2023-06-09 00:45:27 +0000]