TRadio
Source: source/classes/radio.prg
Inherits from: TControl
TRadio implements an individual radio button (auto radio button style). Radio buttons are used in groups where only one option can be selected at a time. They are typically managed by a TRadMenu parent that handles mutual exclusion and keyboard navigation within the group.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
lChecked | Logical | Current checked state of the radio button |
oRadMenu | Object | Parent TRadMenu that manages this radio button group |
nPos | Numeric | Position/index of this button within the group |
Methods
| Method | Description |
|---|---|
New( nRow, nCol, cPrompt, oWnd, bSetGet, lChecked, nPos, oRadMenu ) | Create a radio button; bSetGet is a SETGET code block for the selected value |
Redefine( nId, lChecked, nPos, oDlg, oRadMenu ) | Redefine from a dialog resource |
SetCheck( lOnOff ) | Set the checked state and update Windows button control |
IsChecked() | Query the button's checked state from Windows |
Check() | Set checked to .T. (convenience method) |
UnCheck() | Set checked to .F. (convenience method) |
Click() | Handle click: selects this button in the parent TRadMenu and refreshes |
Commands
@ nRow, nCol RADIO oRad VAR nOpt PROMPT cText OF oDlg
Example: Radio Group with TRadMenu
#include "FiveWin.ch"
function Main()
local oWnd, oRadMenu, nOption := 1
DEFINE WINDOW oWnd TITLE "Radio Demo" SIZE 300, 200
@ 10, 10 RADIO oRadMenu VAR nOption ;
ITEMS "Option &1", "Option &2", "Option &3" ;
OF oWnd SIZE 120, 80
@ 100, 10 BUTTON "Show" SIZE 60, 25 OF oWnd ;
ACTION MsgInfo( "Selected: " + Str( nOption ) )
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- Each TRadio is an
BS_AUTORADIOBUTTONWindows control. The first button in a group should use thelGroupparameter (WS_GROUPstyle) to define group boundaries. - The
lChangedACCESS compares the current checked state to the original value, useful for change tracking. - TRadio buttons are typically created via the
RADIOcommand, which sets up the TRadMenu and individual TRadio objects automatically. - Keyboard navigation (arrow keys) within the group is managed by the parent TRadMenu.