TRadMenu

Fonte: source/classes/radmenu.prg

Standalone class (not derived from TControl)

TRadMenu manages a group of radio button (TRadio) controls as a single logical unit with mutual exclusion: selecting one radio button automatically deselects the others. It provides a simplified interface to create, navigate, and query the state of a radio button group without managing individual TRadio objects.

Key DATA Members

DATATypeDescription
aItemsArrayArray of TRadio objects managed by this group
bSetGetBlockSET/GET code block for the current option index
nOptionNumericIndex of the currently selected option (1-based)
bChangeBlockCode block evaluated when the selection changes

Methods

MethodDescription
New( nRow, nCol, acItems, bSetGet, oWnd )Create a new radio group with items from acItems
ReDefine( bSetGet, oWnd, anIDs )Redefine from dialog resource by control IDs
SetOption( n )Programmatically set the selected option
Refresh()Refresh the display of all items
GoPrev()Select the previous option (circular)
GoNext()Select the next option (circular)
Enable()Enable all radio buttons in the group
Disable()Disable all radio buttons in the group

Example: 3-Option Radio Group

#include "FiveWin.ch"

function Main()

   local oWnd, oRadMenu, nOption := 1

   DEFINE WINDOW oWnd TITLE "Radio Group" SIZE 300, 200

   @ 10, 10 RADMENU oRadMenu ;
      ITEMS { "Option &One", "Option &Two", "Option &Three" } ;
      SIZE 200, 100 OF oWnd ;
      ON CHANGE ( MsgInfo( "Selected: " + Str( oRadMenu:nOption ) ) )

   oRadMenu:bSetGet := {|u| If( u == nil, nOption, nOption := u ) }
   oRadMenu:SetOption( 1 )

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

Veja Também