Previous Topic

Next Topic

Inhoudsopgave

Book Index

TRadioGroup Control

TRadioGroup

Description

Represents a group of radio buttons that function together.

Remarks

A TRadioGroup control is a special group box that contains only radio buttons. Radio buttons that are placed directly in the same control component are said to be "grouped". When the user checks a radio button, all other radio buttons in its group become unchecked. Hence, two radio buttons on a form can be checked at the same time only if they are placed in separate containers, such as group boxes.

To add radio buttons to a TRadioGroup, edit the Items property in the Object Inspector. Each string in Items makes a radio button appear in the group box with the string as its caption. The value of the ItemIndex property determines which radio button is currently selected.

Display the radio buttons in a single column or in multiple columns by setting the Columns property.

TRadioGroup Properties

Property Property Columns: Integer (R/W)

Specifies number of columns in the radio group. Columns determines the number of columns in the radio group. Its value can range from 1 to 16. The default value is 1, which means that the radio buttons are arranged in a single column.

Property Property Items: TStringList (R)

Lists the radio buttons in the radio group. Items holds a TStrings object that lists the captions of the radio buttons in the group. In TCustomRadioGroup descendants, where this property is published, radio buttons can be added or removed by editing the Items list from the Object Inspector.

Note: A TRadioButton object is created automatically for each string in Items. You cannot directly add or remove TRadioButton objects, but you can access individual TButton objects through the Buttons property.

Property Property ItemIndex: Integer (R/W)

Indicates which radio button in the group is currently selected. ItemIndex holds the index of the selected radio button in the Items list. (The first button is 0.) The value of ItemIndex changes at runtime as the user selects radio buttons. If you want one of the buttons to appear selected when the application starts, assign that button to ItemIndex at design time; otherwise, leave ItemIndex set to the default value of -1, which means that no button is selected.